Thanks for confirming that I was on the right trail, Even! I got it figured out: I was naively trying to open the /vsizip/vsimem/ file in update mode.
In case you're interested, my new Python usage is like this: with open(path_zip_file, 'rb') as f: with MemoryFile(f) as memfile: with memfile.open('white-gemini-iv.vrt') as dataset: assert dataset.count == 3 https://github.com/mapbox/rasterio/pull/972/files#diff-d3388b510bd97235e4741b8417cc41e9R148 On Tue, Jan 31, 2017 at 5:42 PM, Even Rouault <even.roua...@spatialys.com> wrote: > On mardi 31 janvier 2017 17:33:23 CET Sean Gillies wrote: > > > Hey all, > > > > > > The tests in > > > https://svn.osgeo.org/gdal/branches/1.9/autotest/gcore/vsizip.py show > how > > > to create a zip archive in memory and create directories and files within > > > it. I'm looking for a shortcut. > > > > > > Given a sequence of bytes representing an existing zip file that > contains a > > > TIFF and a VRT (referencing the TIFF), is it possible to make a VSI file > > > from this buffer (using VISFileFromMemBuffer()) and then access the VRT > > > using a path like /vsizip/vsimem/archive.zip/example.vrt protocol? > > > > Hi Sean, > > > > That sounds like you tested it and something went wrong ? Perhaps check > the path to the source in the VRT and the value of the relativeToVRT > attribute. > > > > Your above strategy does work for me: > > > > $ gdal_translate byte.tif byte.vrt -of VRT > > Input file size is 20, 20 > > > > $ zip byte.tif.zip byte.tif byte.vrt > > adding: byte.tif (deflated 96%) > > adding: byte.vrt (deflated 53%) > > > > $ python > > >>> from osgeo import gdal > > >>> data = open('byte.tif.zip', 'rb').read() > > >>> gdal.FileFromMemBuffer('/vsimem/archive.zip', data) > > >>> ds = gdal.Open('/vsizip/vsimem/archive.zip/byte.vrt') > > >>> ds.GetRasterBand(1).Checksum() > > 4672 > > > > > > Even > > > > > > -- > > Spatialys - Geospatial professional services > > http://www.spatialys.com > -- Sean Gillies
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev