gdal.Open(in_raster) code example

Example: gdal.Open(in_raster)

def write_tile(self, tile, image):
        if tile.z != self._zoom:
            self._init_zoom_layer(tile.z)

        data = QByteArray()
        buff = QBuffer(data)
        image.save(buff, 'PNG')

        mmap_name = '/vsimem/' + uuid4().hex
        gdal.FileFromMemBuffer(mmap_name, data.data())
        gdal_dataset = gdal.Open(mmap_name)
        data = gdal_dataset.ReadRaster(0, 0, self.tile_width, self.tile_height)
        gdal_dataset = None
        gdal.Unlink(mmap_name)

        xoff = (tile.x - self._first_tile.x) * self.tile_width
        yoff = (tile.y - self._first_tile.y) * self.tile_height
        self._zoom_ds.WriteRaster(xoff, yoff, self.tile_width, self.tile_height, data)