Geoscience Reference
In-Depth Information
Chapter 14
Write Your Own Geospatial Utilities
In spite of the variety of GDAL utilities that are available for processing geospatial
raster data, it is likely that at some point you will need some functionality that is
either not available or else does not perfectly match the problem at hand. In case an
acceptable solution is also not found in existing third party utilities, such as pktools
or the Orfeo Toolbox, you can write your own utility. This chapter is written to help
you get started writing your own utilities, based on the GDAL/OGR application
programming interface (API).
The objective is to introduce both the GDAL and OGR APIs through the develop-
ment of some concise geospatial tools that can be used within a geospatial processing
work flow. We do not attempt to provide a detailed introduction to the respec-
tive programming languages and we assume some knowledge of programming.
For those that are interested, we cite some key reference texts on the respective
languages.
We start with an introduction on the general structure of the API and then continue
with a section on each of the Python and C++ programming languages. It is important
to highlight that although the section on Python focuses on OGR and C++ on GDAL,
it is possible to access both the GDAL and OGR APIs from the two languages. The
current choice is related to the respective experience and personal preference of the
authors for vector and raster processing.
14.1 Introduction to API Programming
Figure 14.1 presents a schematic overview of a typical processing chain that is based
on the GDAL/OGRAPI. The building blocks represent the different layers of abstrac-
tion. At the top level, C++ and Python utilities are combined to implement the ensem-
ble of processing tasks. Although this can be implemented in a compiled language,
a scripting language such as Bash, Python or TCL provides more flexibility at this
level. Utilities can then be added and removed without having to recompile the code.
 
Search WWH ::




Custom Search