Open zipped raster files in GDAL

A neat trick you can do with GDAL is open zipped files without unzipping them first. The syntax is described on http://trac.osgeo.org/gdal/wiki/UserDocs/ReadInZip

The first step is to find out the contents of the file (if you don’t already know it), you can do this using the following command:

unzip -l f088013b_mapped_osng_bil.zip

You can then run GDAL commands using the following syntax:

gdalinfo /vsizip/f088013b_mapped_osng_bil.zip/f088013b_mapped_osng.bil

The latest version of TuiView (1.1.3) will automatically search inside the zip file for known raster types and pass the correct path to GDAL so you can view zipped files using:

tuiview f088013b_mapped_osng_bil.zip

You can also use for tar.gz files. Again, get a list of the file contents using:

tar -tf LC80430332013291LGN00.tar.gz

Get file information using:

gdalinfo /vsitar/LC80430332013291LGN00.tar.gz/LC80430332013291LGN00_B1.TIF

Note /vsitar/ is used instead of /vsizip/.

Although this is handy a better option is storing data in a format which supports lossless compression. The KEA image format [1] is one example of a GDAL compatible raster format which uses zlib compression and is capable of storing very large datasets.

You can convert a tar.gz’ipped file to the KEA format using:

gdal_translate -of KEA /vsitar/LC80430332013291LGN00.tar.gz/LC80430332013291LGN00_B1.TIF \
                                       LC80430332013291LGN00_B1.TIF

[1] Bunting, P and Gillingham, S. 2013. The KEA image file format, Computers & Geosciences, Volume 57. Pages 54-58, ISSN 0098-3004, http://dx.doi.org/10.1016/j.cageo.2013.03.025.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s