Programming API | | Linkage with CMake

Programming Example

The following sample code shows how to load a layer, manipulate it, and save it back. It is pretty much self-explanatory, so the code is left to the user to explore on their own.

#include <grid/grid.h>

void main()
   grid_resampler resampler;
   grid_layer *layer;

   // load layer
   if (layer==NULL) exit(1);

   // check for elevation data
   //  images are cell-centered
   //  height fields are grid-centered
   if (!layer->grid_cell_centered)
      // replace elevation values in the range [0..1000] with no-data

      // save to geotiff format (lzw compressed by default)
      if (!"path","output_filename.tif",layer)) exit(1);

Also have a look at the applications in the tools directory, in particular the “gridinfo” tool, which illustrates how to retrieve basic properties such as size and spacing from a grid layer.

Programming API | | Linkage with CMake