I have a GeoJSON file that I have loaded into QGIS as a LineString, and draped over a DEM using Drape (set Z value from raster)
I now want to round the Z-values to 4dp before exporting the modified file back to GeoJSON.
I've tried the following PyQGIS code:
layers = QgsProject.instance().mapLayersByName('Draped')
layer = layers[0]
layer.startEditing()
for f in layer.getFeatures():
geom = f.geometry().get()
for g in geom:
g.setZ(round(g.z(),4))
layer.commitChanges()
The exported file still has the unrounded values, so I'm obviously missing something in the editing phase that commits the change.
Any suggestions?