9

I am working with an Oracle spatial connection in QGIS through which I am accessing and editing a vector layer. I find that when I edit a geometry, the vertex ordering is reversed (to clockwise in the outer ring) which then gets flagged up as an error in oracle.

I am using the combine function (http://www.qgis.org/api/classQgsGeometry.html) among others in my own editing tools, but I notice that this happens with the native merge polygons tool too.

I think this reo-ordering to clockwise is the default in QGIS based on this link: https://hub.qgis.org/issues/6283 and was wondering if there is a way to reverse it to counter clockwise? (preferably with python)

underdark
  • 84,148
  • 21
  • 231
  • 413
user24956
  • 409
  • 1
  • 3
  • 13
  • I don't know how to do this with python, but Oracle Spatial has the SDO_UTIL.RECTIFY_GEOMETRY function that will correct the orientation of polygon rings. https://docs.oracle.com/cd/B28359_01/appdev.111/b28400/sdo_util.htm#BJEICGGA – travis Apr 01 '16 at 15:45

1 Answers1

1

Maybe overdone, but these post might contain some useful hints:

How can I switch line direction in QGIS?

Switch line direction for PostGIS-lines in QGIS or Pgadmin

In PyQGIS the code mentioned there is still valid, I think:

geom = feature.geometry()
nodes = geom.asPolyline()
nodes.reverse() 
newgeom = QgsGeometry.fromPolyline(nodes)
layer.changeGeometry(feature.id(),newgeom)

Since QGIS comes with GRASS support, have a look at v.edit tools=flip https://grass.osgeo.org/grass64/manuals/v.edit.html

[current QGIS version 2.14.5.LTR]

Jochen Schwarze
  • 14,605
  • 7
  • 49
  • 117