Geospatial Data Abstraction Library, or GDAL, is a C and C++ translator library for raster and vector geospatial data formats. As a library, it presents a single raster abstract data model and single vector abstract data model to the calling application for all supported formats. GDAL is widely used in applications such as MapServer, GRASS, QGIS, and MapGuid. More information about this library can be found here.

GDAL example code

A Digital Elevation Model (DEM) file contain height values. We can use GDAL to calculate the average of the height values contained in a sample DEM file. An example code is given bellow:

from osgeo import gdal, gdalconst

import struct

dataset = gdal.open("sample")

band = dataset.GetRasterBand(1)

fm = "<" + ("h" * band.XSize)

totHeight = 0