GDAL Driver - Geospatial Data Abstraction Layer

This driver lets you access raster or elevation data sources through the  GDAL abstraction layer, opening up a wide range of file format and web service support.

This is the driver to use when reading local files in formats such as GeoTIFF, ECW, and MrSID.

Note: The GDAL driver requires GDAL 1.5.0 or greater

Options

url Full pathname to the source dataset. This can reference a single file or a directory of files required
extensions semi-colon delimited list of extensions to query if the url options points to a directory. optional
tile_size Tile size to generate. Defaults to 256. It will generally be better to use a tile_size of 32 or 64 when using a GDAL datasource as a heightfield. optional
max_data_level The maximum level where this datasource will return data. If not set, the maximum data level will be automatically computed. This can be useful when you want to cache tiles past the automatic maximum level for a datasource. optional
interpolation The interpolation method to use for sampling the source data. Valid values are nearest, bilinear and average. Image layers are not sampled unless you use the interp_imagery option. optional
interp_imagery Whether to interpolate imagery using the interpolation setting. Default is false and uses nearest sampling. optional

Example

  <image name="MyRaster" driver="gdal">
      <url>C:\data\MyRaster.tif</url>
  </image>

Performance Tips

  • For best performance, reproject your data source to the coordinate system of the desired map to avoid automatic reprojection of the data at runtime. You can use  gdalwarp to accomplish this. If you do wish to reproject at runtime, you can set up a disk cache with the reproject_before_caching option to improve performance of visualizing cached data.
  • Tiled datasets will generally perform better in osgEarth than non-tiled datasources. For instance, when creating a GeoTiff? using  gdal_translate, use the -co "TILED=YES" option to create a tiled dataset.
  • Adding overviews (also called pyramids or rsets) will greatly increase the peformance of a GDAL datasource in osgEarth. You can use the  gdaladdo utility to add overviews to a dataset.

 Download FWTools to get all the GDAL utilities (and other useful stuff) in one shot.

Hi-resolution insets

The GDAL driver will adapt itself to the profile of the mapping engine, and will reproject raster and elevation data so that it matches up with the map being rendered.

Here's an example of a high-resolution inset. (This example is included in the SVN repository).

<map name="hi-res inset" type="geocentric">

    <image name="blue-marble" driver="tms">
        <url>http://demo.pelicanmapping.com/rmweb/data/bluemarble-tms/tms.xml</url>
    </image>
    
    <image name="boston_inset" driver="gdal">
        <url>../data/boston-inset.tif</url>
        <tile_size>256</tile_size>
    </image>

</map>

Caching reprojected data

If the source data profile doesn't match that of the map, osgEarth will have to reproject it. This can be a slow and processor-intensive operation. One way to mitigate this is a reproject your source data beforehand with a tool such as gdalwarp or Global Mapper. Another way is to set up a cache that will store reprojected tiles:

    <cache reproject_before_caching="true">
        <path>/files/my_cache_folder</path>
    </cache>

The reproject_before_caching directive tells osgEarth to store reprojected tiles in the cache (instead of raw tiles from the data source). The next time the mapping engine needs a tile, no processing will be required.

Loading directories of files

If the URL option points to a directory, the GDAL driver will search the directory recursively and attempt to create a single logical layer from the files using GDAL's VRT capability. This is useful in situations where you may want to keep a directory of elevation files without merging them all together. If you only want to load specific types of files in the directory, you can provide a semi-colon delimited list of extensions via the <extensions> element.

For this capability to work correctly, all of the files in the directory must be in the same coordinate system, have the same number of bands and have the same band interpretation.

Here is an example of how to load a directory of elevation tiles (This example is included in the SVN repository).

<map type="geocentric">

   <!--Load a simple base image of the world-->
   <image name="world" driver="gdal">
       <url>..\data\world.tif</url>
   </image>

    <!--Load a folder full of terrain data as an elevation source-->
    <heightfield name="terrain" driver = "gdal">

      <!--To load the files in a directory, just point the URL to a directory instead of a file-->
      <url>..\data\terrain</url>
     
      <!--Tell the GDAL driver to just look for tifs.  Other files types will be ignored.-->
      <extensions>tif</extensions>  
      <tile_size>32</tile_size>

    </heightfield>
</map>

Driver list