[gdal-dev] Support for reading GDAL datasets in compressed archives (.gz and .zip)

Even Rouault even.rouault at mines-paris.org
Mon Aug 25 17:40:57 EDT 2008


Folks,

I've just commited code in gdal 1.6.0dev SVN trunk that enables GDAL to 
decompress on-the-fly data from GZIP (.gz) and ZIP (.zip) archives.

This is implemented as 2 virtual file systems (like /vsimem for 
example), /vsigzip and /vsizip. Only read-only access is supported.

Note that performance will not be very impressive, as random access to ZIP 
file is slow by nature, although some optimizations have been made to make it 
faster and generally usable.

----------------------------------
To read from a .gz file,
----------------------------------
gdalinfo /vsigzip/path/to/the/file.gz were path/to/the/file.gz is relative or 
absolute.

The first time that a .gz file is read, a small .gz.properties file will be 
generated (if possible) to capture the uncompressed data size. This will make 
following opening of that dataset much faster.

--------------------------------------
* To read from a .zip file,
-------------------------------------
gdalinfo /vsizip/path/to/the/file.zip/path/inside/the/zip/file were 
path/to/the/file.zip is relative or absolute and path/inside/the/zip/file is 
the relative path to the file inside the archive.

For example gdalinfo /vsizip/myarchive.zip/subdir1/file1.tif

The ReadDir() method is implemented for the .zip archives, so a driver will be 
able to find files relative to the given file inside the archive. For 
example, you can read a CADRG dataset from the zipped archive of the a.toc 
file and all its NITF tiles.

Small syntaxic sugar : if the .zip file contains only one file located at its 
root, just mentionning "/vsizip/path/to/the/file.zip" will work.

------------------------------------------------

The fact that this new capability is implemented as virtual file systems imply 
that it will only work for GDAL drivers supporting the "large file API". A 
list of such drivers is : PNG, JPEG, ILWIS, GTiff, GIF, JP2KAK, NITF, ADRG, 
DTED, SRTMHGT, BMP, LCP, HFA (Erdas Imagine), AAIGRID. Other drivers may work 
too (I just looked for those advertizing the GDAL_DCAP_VIRTUALIO capability)

(See http://trac.osgeo.org/gdal/ticket/1369 for the history of that feature.)

Best regards

Even


More information about the gdal-dev mailing list