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:


I tried this, for example:

data = ogr.Simplify(inData)

But then I get an AttributeError:

'module' object has no attribute 'Simplify'

Any tips?

1 Answer 1


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 and acknowledge you have read our privacy policy.

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