On 02/09/2011 04:19 PM, Frank Broniewski wrote:
Hi,

just a quick question: isn't GetNumPoints implemented on a geometry in ogr python?

There are OGR_G_GetPointCount in ogr_api.h and GetPointCount method in the Geometry class in Swig bindings.

Hm. It seems that NumPoints is the name of the method in the OGC simple features standard (it is defined for LineStrings).

Ari

Neither GetNumPoints() nor getNumPoints() (small g) work.
The passed in geometry is a geometry object from a

geometry = feature.GetGeometryRef()

call and the geometry is of type 'LINESTRING' taken from

geometry.GetGeometryName() ...


code:
def line_nodes(geometry):
    nodes = list()

    for point_index in xrange(geometry.GetNumPoints()):
        ogr_point = ogr.OGRPoint()
        point = geometry.GetPoint(point_index, ogr_point)
        dimenion = point.GetCoordinateDimension()
        if dimension == 3:
list.append(point_index, point.GetX(), point.GetY(), point.GetZ())
        else:
            list.append(point_index, point.GetX(), point.GetY())

    return nodes


raises an AttributeError
...
    for point_index in xrange(geometry.getNumPoints()):
File "C:\Python26\lib\site-packages\osgeo\ogr.py", line 2672, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, Geometry, name)
File "C:\Python26\lib\site-packages\osgeo\ogr.py", line 34, in _swig_getattr
    raise AttributeError,name
AttributeError: GetNumPoints


Many thanks

Frank


_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to