osgdem is utility program for reading geospatial imagery and digital elevation maps (DEM's) and generating large scale 3D terrain databases that OpenSceneGraph applications can load and browse in real-time. What follows is a step-by-step guide to using osgdem, followed by a list of full options available.

Quick step by step guide

What follows are the steps required to get VirtualPlanetBuilder/osgdem compiling and an example of how to use it to process imagery and DEM's to generate a paged databases.

6. Now its time to run the osgdem example to generate your PagedLOD database, the more levels you generate the longer it will take (exponentially so). 'osgdem' is just a front end to osgTerrain::DataSet where all the hard work happens. Here's what to run :

Then go away for lunch, afternoon and tea, as generating this much data takes a while... If you don't wish to wait for the full database then reduce the number of levels it generates by setting the -l option to a lower value such as 3. The command line options used above are: The first part the --xx and --yy is specifying the size of the pixels in meters, since these png/tif don't have any geospatial data of their own, if you have geospatialised files then you won't need this.

The second part -t <filename> is the option for specificing the texture maps to use, you can use as many times as you wish, osgTerrain::DataSet will moziac them into a single database.

The third part -d is the option for specifying the digital elevation maps to use, as with the textures you can use as many as you like.

The -l option specificies the maximum number of levels to generate. If you use a large number then the database generation will stop once the max resolution of your source data is matched by the resulting database. The database generation will decend further where there is high res source data, decend less where there is lower res data.

The -v option specifies the scaling factor which the height is multiplied by.

The -o <filename> is the output format to generate the databases in. This will be the name of the topmost file in the one you should load. It can be a .ive or a .osg. The .ive is faster and has embedded files.

And finally the -a <filename> tells the osgdem to write all tiles to a single archive, in this a the OpenSceneGraph native archive format, which uses the extension .osga to disguinish itself. The use of archives is not required, but is recommend since it makes managment of the whole database much more convinient - you have a single file to manage rather than what could be 10's of thousands as is the case of large databases.

7. Time to play. Simply load the database in your app, and if you've based it on osgViewer::Viewer or CompositeViewer all the paging support is already built in. The standard osgviewer works just fine so, here goes:

osgviewer pegout.osga

8. If your imagery and DEMs have geospatial coords associated with them then the -xx, --yy and -v options will not be required, making it much simplier to specify - you just need to specifiy options such as -t imge.tif and -d terran.dt0 without any need to set the coordinate system.

9. osgdem can automatically handle mosaicing of sets of files. These can be specified via a sequence of -t <filename> and -d <filename> pairs on the commandline, or via -t <directoryname> and -d <directoryname>.

Coordinate System Tips

WKT coordinate system definition format is a very comprehensive, but difficult to use as a "human enter-able" specifier for coordinate systems. osgdem uses GDAL under the hood which also allows definition of the --cs flag in PROJ4 format. PROJ4's definition format is much more human friendly.