[Qgis-developer] Re: cannot call QgsVectorDataProvider.changeGeometryValues() from python

Bob English bobengl at gmail.com
Wed Jan 18 13:17:08 EST 2012


Hi,

See https://github.com/EcoGIS/CAPS-Scenario-Builder to download lots of well
commented python code.

See http://qgis.org/pyqgis-cookbook/index.html

This code works for me.  I'm using the 1.71API and my app is a desktop app
rather than a plugin.

feat = QgsFeature()
roundPointGeom = None
while provider.nextFeature(feat):
                point = feat.geometry().asPoint()
                roundPointGeom =
QgsGeometry.fromPoint(QgsPoint(round(point.x(), 2), round(point.y(), 2)))
                provider.changeGeometryValues({feat.id(): roundPointGeom})

and

elif vlayer.geometryType() == 1: # line
            while provider.nextFeature(feat):
                roundedLine = []
                line = feat.geometry().asPolyline()
                for point in line: 
                    roundedLine.append(QgsPoint(round(point.x(), 2),
round(point.y(), 2)))
                    provider.changeGeometryValues({feat.id():
QgsGeometry.fromPolyline(roundedLine)})
 

-----
Daystar
...computing and research services
367 Four Mile Brook Rd.
Northfield, MA 01360
Phone: (413)834-2076
Fax: (978)882-0243
bobengl at gmail.com
Check out the updated CV/Resume:
http://edaystar.com
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/cannot-call-QgsVectorDataProvider-changeGeometryValues-from-python-tp7195861p7201037.html
Sent from the qgis-developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list