[gdal-dev] Accessing GDAL/OGR From Python: Simple Feature and Rasters

Frank Warmerdam warmerdam at pobox.com
Thu Nov 26 12:24:41 EST 2009


Sunburned Surveyor wrote:
> Is there a OGR programming construct to represent a simple feature? 

Landon,

The OGRGeometry class represents a simple feature geometry.  The
OGRFeature class extends this to a feature with attributes and
a feature id.  I would suggest reviewing the OGR Architecture
document at:

   http://www.gdal.org/ogr/ogr_arch.html

 > If
> there is, can you tell me where to look for the Python files that
> would represent these simple features? 

GDAL/OGR includes excellent Python bindings.  Some background
information is available at:

   http://trac.osgeo.org/gdal/wiki/GdalOgrInPython

 > Is there any example Python
> code that will show me how to obtain simple features from an ESRI
> Shapefile?

The GdalOgrInPython doc points to a variety of samples and utilities
implemented in Python.  The:

http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/get_soundg.py

script is an example of reading features from one source and writing
them to a shapefile and might be helpful.  The

http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/gdal2xyz.py

script reads a raster and converts to x/y/z text format and might
be a decent model for accessing raster data.

> I also need to know if GDAL has programming constructs to work with
> elevation grids. If it does, where do I look for those Python files?

Elevation grids are rasters covered by the "GDAL" side of GDAL/OGR.
You would "from osgeo import gdal" to get the interfaces.  Lots of docs
on the GDAL page including:

   http://www.gdal.org/gdal_tutorial.html
   http://www.gdal.org/gdal_datamodel.html

> I know everyone is busy. I don't want anyone to write my code for me,
> but any suggestions on where I start looking in the source code so I
> can learn how to do what I need with the library is appreciated.

With all respect I *feel* like you haven't yet really made a major
effort to scour the GDAL/OGR web site for information yet.

> I will make a commitment to make documentation/Python code for working
> with GDAL/ODR that results from our project available to everyone that
> is interested.

It might be suitable for submission to the Python samples directories.
Also feel free to improve the GdalOgrInPython Trac page.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list