Created
May 4, 2011 12:04
-
-
Save NathanW2/955121 to your computer and use it in GitHub Desktop.
Swap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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