Changes between Initial Version and Version 1 of UserDocs/ReadInZip


Ignore:
Timestamp:
Sep 8, 2008, 12:01:34 PM (16 years ago)
Author:
Even Rouault
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UserDocs/ReadInZip

    v1 v1  
     1= Reading a GDAL dataset in a .gz file or a .zip archive =
     2
     3== Summary ==
     4
     5From GDAL 1.6.0, it is possible to access a GDAL dataset inside a compressed archive and read it on-the-fly.
     6The archive formats that are handled are single gzip'ed file (ending with .gz) and ZIP archives (ending with .zip)
     7
     8This is implemented as 2 virtual file systems (like /vsimem for
     9example), /vsigzip and /vsizip. Only read-only access is supported.
     10Note that performance will not be very impressive, as random access inside gzip data
     11is slow by nature, although some optimizations have been made to make it
     12faster and generally usable ("snapshots" of the gzip state are taken from time to time, so
     13that further access to a given offset inside the file just needs to restart decompression
     14from the nearest snapshot)
     15
     16Note that .tar.gz archives are not supported, and there's no plan to support them
     17as it is a very inappropriate format for seeking.
     18
     19== How to use that capability with a gzip file ? ==
     20
     21For example :
     22{{{
     23gdalinfo /vsigzip/path/to/the/file.gz
     24}}}
     25were path/to/the/file.gz is relative or absolute. If the path is absolute, it should begin with a /, so the line looks like /vsigzip//home/gdal/...
     26
     27The first time that a .gz file is read, a small .gz.properties file will be
     28generated (if possible) to capture the uncompressed data size. This will make
     29following opening of that dataset much faster.
     30
     31A VSIStatL("/vsigzip/...") call will return the uncompressed size of the file.
     32
     33== How to use that capability with a ZIP archive ? ==
     34
     35{{{
     36gdalinfo /vsizip/path/to/the/file.zip/path/inside/the/zip/file
     37}}}
     38
     39were path/to/the/file.zip is relative or absolute and path/inside/the/zip/file is
     40the relative path to the file inside the archive.
     41
     42For example gdalinfo /vsizip/myarchive.zip/subdir1/file1.tif
     43
     44The ReadDir() method is implemented for the .zip archives, so a driver will be
     45able to find files relative to the given file inside the archive. For
     46example, you can read a CADRG dataset from the zipped archive of the a.toc
     47file and all its NITF tiles.
     48
     49A VSIStatL("/vsizip/...") call will return the uncompressed size of the file.
     50Directories inside the ZIP file can be distinguished from regular files with
     51the VSI_ISDIR(stat.st_mode) macro as for regular file systems.
     52
     53Small syntaxic sugar : if the .zip file contains only one file located at its
     54root, just mentionning "/vsizip/path/to/the/file.zip" will work.
     55
     56== Drivers supporting that capability ==
     57
     58The fact that this new capability is implemented as virtual file systems imply
     59that it will only work for GDAL drivers supporting the "large file API". A
     60list of such drivers is : PNG, JPEG, ILWIS, GTiff, GIF, JP2KAK, NITF, ADRG,
     61DTED, SRTMHGT, BMP, LCP, HFA (Erdas Imagine), AAIGRID. Other drivers may work
     62too (I just looked for those advertizing the GDAL_DCAP_VIRTUALIO capability)