[gdal-dev] Opening VRT files within zip archive using /vsizip

Scott Arko saarko at alaska.edu
Tue Sep 26 14:08:18 PDT 2017


Hello,


I have found an odd behavior using the /vsizip driver and I'm hoping
someone on this list can explain what is happening.

I have a zip file containing a number of files of various types.  For each
different dataset there is also a vrt file that is generated by the
processing software to access the various binary data files.  If I access
one of the vrt files via the command line tools I get something along the
lines of:

/opt/local/bin/gdalinfo
/vsizip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf.zip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf/merged/phsig.cor.geo.vrt
ERROR 1: Random access not supported for /vsizip
Driver: VRT/Virtual Raster
Files:
/vsizip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf.zip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf/merged/phsig.cor.geo.vrt

 /vsizip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf.zip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf/merged/phsig.cor.geo
Size is 5139, 6060
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
Origin = (-112.731111111111105,33.272777777777776)
Pixel Size = (0.000277777777778,-0.000277777777778)
Corner Coordinates:
Upper Left  (-112.7311111,  33.2727778) (112d43'52.00"W, 33d16'22.00"N)
Lower Left  (-112.7311111,  31.5894444) (112d43'52.00"W, 31d35'22.00"N)
Upper Right (-111.3036111,  33.2727778) (111d18'13.00"W, 33d16'22.00"N)
Lower Right (-111.3036111,  31.5894444) (111d18'13.00"W, 31d35'22.00"N)
Center      (-112.0173611,  32.4311111) (112d 1' 2.50"W, 32d25'52.00"N)
Band 1 Block=5139x1 Type=Float32, ColorInterp=Undefined


This seems perfectly normal and if I use gdal_translate to convert the file
to geotiff it looks fine.  Note that I do get the Error 1 message, but this
does not seem to impact access.  The problem enters when I try to access
the file via the gdal python module.

>>> from osgeo import gdal
>>> han =
gdal.Open('/vsizip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf.zip/S1-IFG_RM_M1S2_TN027_20170301T132816-20170217T132724_s2-poeorb-76d1-v1.1.3-asf/merged/phsig.cor.geo.vrt',gdal.GA_ReadOnly)
ERROR 1: Random access not supported for /vsizip

Notice the filename is exactly the same as I used with gdalinfo.  I also
get the same Error 1 message.  However, this does not actually open the
file.  I have tried using the GA_ReadOnly flag and not using it with the
same result.

>>> print han
None
>>> print han.GetGeoTransform()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'GetGeoTransform'

The VRT file looks like this:

VRTDataset rasterXSize="5139" rasterYSize="6060">
    <SRS>EPSG:4326</SRS>
    <GeoTransform>-112.7311111111111, 0.0002777777777777778, 0.0,
33.272777777777776, 0.0, -0.0002777777777777778</GeoTransform>
    <VRTRasterBand band="1" dataType="Float32" subClass="VRTRawRasterBand">
        <SourceFilename relativeToVRT="1">phsig.cor.geo</SourceFilename>
        <ByteOrder>LSB</ByteOrder>
        <ImageOffset>0</ImageOffset>
        <PixelOffset>4</PixelOffset>
        <LineOffset>20556</LineOffset>
    </VRTRasterBand>
</VRTDataset>


I initially thought the problem might be the relativeToVRT=1 flag, since I
found an ealier thread in this email list that seems to say that relative
paths are not allowed in the /vsizip driver.  However, if that were the
case I would have expected the gdalinfo call to fail as well, but it does
not.

Apologies if this is not the right list for this type of question.  I have
been fighting with variants of this problem for a while now and am a bit
frustrated.  We want to provide these data files to our users and allow
them to access the various layers in place, without unzipping the files.
However, I just can't seem to get this to work.  I would appreciate any
comments or thoughts.

Thank you,
Scott




-- 
Scott Arko
Alaska Satellite Facility Deputy Director
University of Alaska Fairbanks

903 Koyukuk Drive
Fairbanks, AK 99775
Phone: (907) 474 - 5570
email:  saarko at alaska.edu
http://www.asf.alaska.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170926/7947c49c/attachment.html>


More information about the gdal-dev mailing list