Skip to content

Instantly share code, notes, and snippets.

@NathanW2
Created May 4, 2011 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanW2/955121 to your computer and use it in GitHub Desktop.
Save NathanW2/955121 to your computer and use it in GitHub Desktop.
Swap
def run():
layer = qgis.utils.iface.mapCanvas().currentLayer()
for feature in layer.selectedFeatures():
geom = feature.geometry()
nodes = geom.asPolyline()
print nodes
nodes.reverse()
print nodes
newgeom = QgsGeometry.fromPolyline(nodes)
print newgeom
feature.setGeometry(newgeom)
print feature.geometry()
print feature.geometry().asPolyline()
#output
[(-0.0269439,-0.00117298), (0.02239,0.0102118), (0.022045,-0.0113848)]
[(0.022045,-0.0113848), (0.02239,0.0102118), (-0.0269439,-0.00117298)]
<qgis.core.QgsGeometry object at 0xa58b9ac>
<qgis.core.QgsGeometry object at 0xa58ba2c>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment