Yes, thank you. GetPointCount() works. Another thing I noticed:
point = geometry.GetPoint(point_index)
point is of type tuple(x, y, z), not as one would guess an OGRPoint()
geometry. At least for me this was unexpected. And the python GetPoint
method does not take a OGRPoint geometry, like it is mentioned here [1]
Frank
[1]
http://www.gdal.org/ogr/classOGRLineString.html#ab63760022e49a795477f2fd31da059f
Am 09.02.2011 15:44, schrieb Ari Jolma:
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
--
Frank BRONIEWSKI
METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN
tél.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev