Child pages
  • GDAL
Skip to end of metadata
Go to start of metadata

GDAL is a translator library for raster geospatial data formats that is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single abstract data model to the calling application for all supported formats. It also comes with a variety of useful commandline utilities for data translation and processing. The NEWS page describes the May 2012 GDAL/OGR 1.9.1 release.

The main page can be found on gdal.org. You can find how to install GDAL on this page. If you desire QGIS, then it is recommended to install QGIS, including GDAL via the OSGeo4Setup utitility. This allows you to get hold on the latest versions of QGIS and GDAL utitlities.
A good recipe for installing without QGIS is describe on this blog

For a compiled Windows(executable) version you can go to http://www.gisinternals.com/sdk and chose the appropriate development, stable of release version of gdal and than download the core version (something like gdal-19-1600-core.msi). The python binding can also be found here.

Below you can find various tips to use the various GDAL utitilities. You are requested to append tips and trics.

GDAL info

One of the main GDAL utilities is gdalinfo. This utility gives you information on the various formats that are supported by GDAL.
Main syntax is

gdalinfo filename
Conversion

- netCDF --> ArcINFO ASCII raster
use gdalinfo <filename.nc> to find out which subdatasets are available in your nc. For instance in maaiveld25.nc the following subdatasets are available.

Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"maaiveld_25.nc":Band1
  SUBDATASET_1_DESC=[1775x3782] surface_elevation (32-bit floating-point)
  SUBDATASET_2_NAME=NETCDF:"maaiveld_25.nc":legend
  SUBDATASET_2_DESC=[100x3] legend (16-bit integer)
  SUBDATASET_3_NAME=NETCDF:"maaiveld_25.nc":legend_values
  SUBDATASET_3_DESC=[100x2] legend_values (32-bit floating-point)
  SUBDATASET_4_NAME=NETCDF:"maaiveld_25.nc":legend_description
  SUBDATASET_4_DESC=[100x80] legend_description (8-bit character)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

By using the following syntax you can convert the maaiveld25.nc to mv.asc

gdal_translate -of AAIGrid NETCDF:"maaiveld25.nc":Band1 mv.asc

In the example above the part NETCDF:"maaiveld25.nc":Band1 can be different in any other netCDF. For instance the netCDF (INTER_OPER_R__TAVGD_L3_20110831T000000_20110901T000000_0005.nc) that can be downloaded from the NMDC site gives the following gdalinfo information

Subdatasets:
  SUBDATASET_1_NAME=HDF5:"D:\test\INTER_OPER_R___TAVGD___L3__20110831T000000_20110901T000000_0005.nc"://lat
  SUBDATASET_1_DESC=[319x273] //lat (32-bit floating-point)
  SUBDATASET_2_NAME=HDF5:"D:\test\INTER_OPER_R___TAVGD___L3__20110831T000000_20110901T000000_0005.nc"://lon
  SUBDATASET_2_DESC=[319x273] //lon (32-bit floating-point)
  SUBDATASET_3_NAME=HDF5:"D:\test\INTER_OPER_R___TAVGD___L3__20110831T000000_20110901T000000_0005.nc"://prediction
  SUBDATASET_3_DESC=[1x319x273] //prediction (32-bit floating-point)
  SUBDATASET_4_NAME=HDF5:"D:\test\INTER_OPER_R___TAVGD___L3__20110831T000000_20110901T000000_0005.nc"://stations
  SUBDATASET_4_DESC=[1x319x273] //stations (32-bit floating-point)
  SUBDATASET_5_NAME=HDF5:"D:\test\INTER_OPER_R___TAVGD___L3__20110831T000000_20110901T000000_0005.nc"://stationvalues
  SUBDATASET_5_DESC=[1x319x273] //stationvalues (32-bit floating-point)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

Check the subdataset name subdataset_3_name. It starts with HDF5 and ends with //prediction. This Entire name has to be used to derive data from this netcdf. So everything after the SUBDATASET_3_NAME=. The export to ASCII is

gdal_translate -of AAIGrid HDF5:"INTER_OPER_R___TAVGD___L3__20110831T000000_20110901T000000_0005.nc"://prediction
 prediction.asc

Note the pathname, this is not used. Exporting is best done from the location where the netCDF is stored.