[gdal-dev] About the interaction between VRT and VSIMEM
sean at mapbox.com
Wed Sep 23 13:03:05 PDT 2020
I've written a test for rasterio and the output has me scratching my head.
The gist of it: It creates a VSIMEM file copied from an ordinary GeoTIFF on
my filesystem, calls GDALOpenEx on the VSIMEM file to get a handle, calls
GDALAutoCreateWarpedVRT with that handle to make a warped VRT and then it
deletes the VSIMEM dataset. In Python it looks like
with open("RGB.byte.tif", "rb") as fp:
data = fp.read()
with MemoryFile(data) as memfile: # copies the bytes to a
/vsimem/foo/bar.tif file, the exact name isn't important.
with memfile.open() as rgb:
vrt = WarpedVRT(rgb, dst_crs="EPSG:3857") # there are two
GDALDatasetH in the program now, one on /vsimem/foo/bar.tif and one on the
in-memory warped VRT that references the /vsimem file.
# At this point /vsimem/foo/bar.tif is closed.
# At this point /vsimem/foo/bar.tif is deleted. I've confirmed by calling
arr = vrt.read()
I'm able to read data from the warped VRT after the VSIMEM file it
references has been deleted. I'm not sure how to interpret this. Was the
raster data of /vsimem/foo/bar.tif cached somewhere? Did the GeoTIFF driver
not actually delete the VSIMEM file?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev