3.4. Geospatial Data Abstraction Library (GDAL)

 < Day Day Up > 

GDAL is part of the FWTools package available at http://fwtools.maptools.org. GDAL's home page (http://www.gdal.org) describes the project as:

...a translator library for raster geospatial data formats... As a library, it presents a single abstract data model to the calling application for all supported formats.

GDAL (often pronounced goodle) has three important features. First, it supports over 40 different raster formats. Second, it is available for other applications to use. Any application using the GDAL libraries can access all its supported formats, making custom programming for every desired format unnecessary. Third, prebuilt utilities help you use the functionality of the GDAL programming libraries without having to write your own program.

These three features offer a powerhouse of capability: imagine not worrying about what format an image is in. With GDAL supporting dozens of formats, the odds are that the formats you use are covered. Whether you need to do data conversion, display images in your custom program, or write a new driver for a custom image format, GDAL has programming interfaces or utilities available to help.

3.4.1. Raster Formats Supported by GDAL

GDAL supports dozens of raster formats. This list is taken from the GDAL web site formats list page found at http://www.gdal.org/formats_list.html.

Arc/Info Binary Grid (.adf)
Microsoft Windows Device Independent Bitmap (.bmp)
BSB Nautical Chart Format (.kap)
VTP Binary Terrain Format (.bt)
CEOS (Spot, for instance)
First Generation USGS DOQ (.doq)
New Labelled USGS DOQ (.doq)
Military Elevation Data (.dt0, .dt1)
ERMapper Compressed Wavelets (.ecw)
ESRI .hdr labeled
ENVI .hdr labeled Raster
Envisat Image Product (.n1)
EOSAT FAST Format
FITS (.fits)
Graphics Interchange Format (.gif)
Arc/Info Binary Grid (.adf)
GRASS Rasters
TIFF/GeoTIFF (.tif)
Hierarchical Data Format Release 4 (HDF4)
Erdas Imagine (.img)
Atlantis MFF2e
Japanese DEM (.mem)
JPEG, JFIF (.jpg)
JPEG2000 (.jp2, .j2k)
NOAA Polar Orbiter Level 1b Data Set (AVHRR)
Erdas 7.x .LAN and .GIS
In Memory Raster
Atlantis MFF
Multi-resolution Seamless Image database
NITF
NetCDF
OGDI Bridge
PCI .aux labeled
PCI Geomatics database file
Portable Network Graphics (.png)
Netpbm (.ppm, .pgm)
USGS SDTS DEM (*CATD.DDF)
SAR CEOS
USGS ASCII DEM (.dem)
X11 Pixmap (.xpm)

This list is comprehensive but certainly not static. If a format you need isn't listed, you are encouraged to contact the developers. Sometimes only a small change is required to meet your needs. Other times it may mean your request is on a future enhancement waiting list. If you have a paying project or client with a particular need, hiring the developer can make your request a higher priority. Either way, this is one of the great features of open source software development direct communication with the people in charge of development.

All these formats can be read, but GDAL can't write to or create new files in all these formats. The web page shown earlier lists which ones GDAL can create.

3.4.2. Programming Libraries

As mentioned earlier, an important feature of GDAL is its availability as a set of programming libraries. Developers using various languages can take advantage of GDAL's capabilities, giving them more time to focus on other tasks. Custom programming to support formats already available through GDAL isn't necessary: reusability is a key strength of GDAL.

GDAL's application programming interface (API) tutorial shows parallel examples of how to access raster data using C, C++, and Python. You can also use the Simplified Wrapper and Interface Generator (SWIG) to create interfaces for other programming languages such as Perl, Java, C#, and more. See http://www.swig.org/ for more information on SWIG.

The ability to directly link to GDAL libraries has helped add features to an array of GIS and visualization programs both commercial and open source. The GDAL website lists several projects that use GDAL, including FME, MapServer, GRASS, Quantum GIS, Cadcorp SIS, and Virtual Terrain Project.

3.4.3. GDAL Utilities

GDAL also has some powerful utilities. Several command-line data access/manipulation utilities are available. All use the GDAL libraries for tasks such as the following:


gdalinfo

Interrogates a raster/image file and gives information about the file. This command, when given a raster file/data source name, provides a listing of various statistics about the data, as shown in the following code:

     # gdalinfo vancouver.tif     Driver: GTiff/GeoTIFF     Size is 1236, 1028     Coordinate System is:     PROJCS["NAD83 / UTM zone 10N",         GEOGCS["NAD83",             DATUM["North_American_Datum_1983",                 SPHEROID["GRS 1980",6378137,298.2572221010042,                     AUTHORITY["EPSG","7019"]],                 AUTHORITY["EPSG","6269"]],             PRIMEM["Greenwich",0],             UNIT["degree (supplier to define representation)",0.01745329251994328],             AUTHORITY["EPSG","4269"]],         PROJECTION["Transverse_Mercator"],         PARAMETER["latitude_of_origin",0],         PARAMETER["central_meridian",-123],         PARAMETER["scale_factor",0.9996],         PARAMETER["false_easting",500000],         PARAMETER["false_northing",0],         UNIT["metre",1,             AUTHORITY["EPSG","9001"]],         AUTHORITY["EPSG","26910"]]     Origin = (480223.000000,5462627.000000)     Pixel Size = (15.00000000,-15.00000000)     Corner Coordinates:     Upper Left  (  480223.000, 5462627.000) (123d16'19.62"W, 49d18'57.81"N)     Lower Left  (  480223.000, 5447207.000) (123d16'16.88"W, 49d10'38.47"N)     Upper Right (  498763.000, 5462627.000) (123d 1'1.27"W, 49d18'58.96"N)     Lower Right (  498763.000, 5447207.000) (123d 1'1.10"W, 49d10'39.61"N)     Center      (  489493.000, 5454917.000) (123d 8'39.72"W, 49d14'48.97"N)     Band 1 Block=256x256 Type=Byte, ColorInterp=Red     Band 2 Block=256x256 Type=Byte, ColorInterp=Green     Band 3 Block=256x256 Type=Byte, ColorInterp=Blue 

Various pieces of important information are shown here: image format, size, map projection used (if any), geographic extent, number of colors, and pixel size. All these pieces of information can be very useful when working with data, particularly data that is from an external source about which little is known.


gdal_translate

Translates a raster/image between formats. It has numerous powerful functions such as image resizing, adding ground control points for geo-referencing, and taking subsets of data. This tool can also manipulate any supported format for other purposes, such as web or graphic design. This is particularly useful when images are very large and not easily handled by other software.


gdaladdo

Adds overview levels to a file. This feature improves application performance viewing a file. Applications that are able to read these overviews can then request appropriate resolutions for the display and map scale without loading the full resolution of the file into memory. Instead, portions of an image at reduced resolution are quickly provided.


gdalwarp

Takes a source image and reprojects it into a new image, warping the image to fit the output coordinate system. This is very useful when source data isn't in the required coordinate spatial reference system. For example, a geo-referenced satellite image may be projected into UTM projection with meter units, but the application requires it to be unprojected in geographic coordinates (latitude/longitude) measured in degrees.


gdal_merge.py

A very powerful tool that takes multiple input images and stitches them together into a single output image. It is a Python script that requires the Python interpreter software to be installed on your system and the GDAL Python module to be loaded. This is a good example of how powerful programs can be built on top of GDAL using higher-level languages such as Python. See http://python.org/ for more information about the programming language. Recent download packages of FWTools include GDAL and Python as well. See http://fwtools.maptools.org/.


gdaltindex

Creates or appends the bounds of an image into an index shapefile. You run gdaltindex with image names as a parameter. GDAL checks the geographic extents of the image and creates a rectangular shape. The shape and the name of the image files are then saved to the output shapefile. This image index can be used by MapServer to define a single layer that is actually made up of more than one image. It works as a virtual image data source and helps MapServer find the right image efficiently.

In general, GDAL aids in accessing, converting, and manipulating rasters/images. When further programming is done using languages such as Python, GDAL can also serve as a powerful analysis tool. In one sense GDAL can also be used as a rough viewing tool because it allows conversion into commonly viewable formats (e.g., JPEG) for which many non-GIS users may have viewing software.

If you use the GDAL utilities that come with FWTools for Windows, you will have a desktop icon called FWTools Shell. This launches a command window for running these utilities.


     < Day Day Up > 


    Web Mapping
    Web Mapping Illustrated: Using Open Source GIS Toolkits
    ISBN: 0596008651
    EAN: 2147483647
    Year: 2005
    Pages: 138

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net