How can I get the wkt from a geometry object in python?
I'd like to be able to do something like the following:
from qgis.core import *
import qgis.utils
layer = qgis.utils.iface.activeLayer()
for feat in layer.getFeatures():
geom = feat.geometry()
#print something meaningful about the geom object
I've checked dir(geom)
, but there doesn't seem to be an option to get a wkt.
Best Answer
In QGIS 3 there was a backwards incompatible change about this:
So now it is:
your_string = geom.asWkt()