[Qgis-developer] Poligon coordinates in PyQgis 2
Geo DrinX
geodrinx at gmail.com
Fri Oct 18 01:57:12 PDT 2013
I found a way to have coordinates:
layer = qgis.utils.iface.activeLayer()
for elem in layer.getFeatures():
geom= elem.geometry()
elem = geom.asPolygon()
for iii in range (len(elem)):
for jjj in range (len(elem[iii])):
x1,y1 = elem[iii][jjj][0], elem[iii][jjj][1]
Is this the unique way ? Nothing of more elegant ?
For what reason, in the linestring case I can write something like this:
layer = qgis.utils.iface.activeLayer()
for elem in layer.getFeatures():
geom= elem.geometry()
poly = geom.asPolyline()
for p1 in elem:
x1,y1 = p1.x(),p1.y()
print ('%lf,%lf \n') % (x1,y1)
...and, instead, in polygon there is not a x() y() method ?
:)
Thank you
Roberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131018/96433eb5/attachment.html>
More information about the Qgis-developer
mailing list