[gdal-dev] Problem using VSIMem to open VRT dataset

Even Rouault even.rouault at mines-paris.org
Sun Jun 28 13:24:47 EDT 2009


Dan,

I'm not sure if I've completely understood what you meant but here's a small 
python script that tries to reproduce what I've understood from your 
scenario :

import gdal
content = """<VRTDataset rasterXSize="1" rasterYSize="1">
  <GeoTransform>100,1,0,100,0,-1</GeoTransform>
  <VRTRasterBand dataType="Byte" band="1">
  </VRTRasterBand>
</VRTDataset>"""

gdal.FileFromMemBuffer('/vsimem/test.vrt', content)

ds = gdal.Open('/vsimem/test.vrt')
ds.SetGeoTransform([2,1,0,49,0,-1])
ds = None # Closes the dataset and updates /vsimem/test.vrt

ds = gdal.Open('/vsimem/test.vrt')
print ds.GetGeoTransform()
# Displays (2.0, 1.0, 0.0, 49.0, 0.0, -1.0) as expected
ds = None

gdal.Unlink('/vsimem/test.vrt')

So that works fine for me.

Best regards,
Even

Le Thursday 25 June 2009 22:13:18 Dan Greve, vous avez écrit :
> Frank,
>
> I've noticed some issues when using /vsimem/ to open a VRT dataset (among
> other formats).  The code usually fails @ GDALClose or FlushCache, when the
> dataset tries to perform a VSIMemFile::SetLength, and ultimately a realloc.
> Many formats I can only VSIUnlink, and don't try to close the dataset. I
> was going to submit a bug report.
>
> I'm trying to SetGeotransform like the tfw to 0,1,0,0,0,-1 in order to
> perform a pixel space gdalwarp interopolation (i've actually wrapped the
> gdal utilities into a single DLL to perform more integrated exception
> handling).  So it tries to open the same /vsimem/ VRT that was modified,
> but it still has the old geotransform.  Short term i'll probably add a
> parameter to the utilities to pass the GDALDataset (source and destination)
> back and from from GDALWarp, but it's a little more code i have to merge
> with each GDAL version upgrade.
>
> -- Dan Greve
> -- Palm Bay, FL
>
> _________________________________________________________________
> Hotmail® has ever-growing storage! Don’t worry about storage limits.
> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutori
>al_Storage_062009




More information about the gdal-dev mailing list