[Gdal-dev] Problem with geometry

Frank Warmerdam warmerdam at pobox.com
Thu Nov 9 09:46:37 EST 2006

vuilleumier vincent wrote:
> Hi, I'm making a little GIS application in python using wxPython for the
> layout. To do this, I need to read the (x, y) of each feature on a layer.
> With a point's feature I use the GetX and GetY's methods, but I don't know
> how to do with a polygon's feature or line's feature. For this two
> features, I need to read the x, y of all the points to draw them back on a
> canvas. Knows someone the methods to use ?


You would use the GetX() and GetY().  These methods include a vertex #.  For
lines you would need to pass this.   You can find how many vertices there are
by calling the Geometry.GetPointCount() method.

For polygons you need to fetch back the ring geometries, and then fetch the
points from them in the same way you would with a line.  You can use the
Geometry.GetGeometryCount() method to find how many geometries there are, and
the Geometry.GetGeometryRef() method to fetch back the rings.

Good luck,
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    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list