2

I am trying to simplify several polygons part of one shapefile using Python and OGR. However, I am stuck with how to use the simplify function as mentioned in the documentation:

http://www.gdal.org/classOGRGeometry.html#a0f4d7948332d9efd6548e1cf87bb6c8f

I tried this, for example:

data = ogr.Simplify(inData)

But then I get an AttributeError:

'module' object has no attribute 'Simplify'

Any tips?

6

If you look at the link you provided, you will see that Simplify is a method of the OGRGeometry class. In Python, Simplify is a method (member-function) of ogr.Geometry.

OGRGeometry * OGRGeometry::Simplify ( double  dTolerance ) const


#! /usr/bin/python
import ogr

shp = ogr.Open('input.shp', 0)
lyr = shp.GetLayer()
feat = lyr.GetFeature(0)
geom = feat.geometry()
simple = geom.Simplify(2.0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.