Looking at the source, 2.99 seems to fix the issue that the multipart to
singlepart vector geometry tool does not preserve Z values for 3d
geometries. 2.18.10 seems to still have this issue, at least 2.18.3 has it.

It turns out that it is straightforward to backport the 2.99 fix to 2.18,
so I thought it may be useful to share the fix:

After backing up the installed

qgis/python/plugins/processing/algs/qgis/MultipartToSingleparts.py

file, edit this file at the bottom (with notepad++ or emacs) and change the
function extractAsSingle to (this much shorter) definition:

def extractAsSingle(self, geom):
       print('multipart2single: use .asGeometryCollection')
       multiGeom = QgsGeometry()
       geometries = []
       if geom.isMultipart():
           multiGeom = geom.asGeometryCollection()
           for g in multiGeom:
               geometries.append(g)
       else:
           geometries.append(geom)
       return geometries

.asGeometryCollection() preserves Z, while the original .as or .from
methods do not.

Also rename the corresponing MultipartToSinglePart.pyc and .pyo files to
something else.

Restart qgis and try it out. This is only tested on linux and with
MultiPointZ but may work with other types as well.

Good luck,

Andreas

PS: I did not submit this as a PR to the github repo since the issue seems
already fixed and the strict requirements for a PR.
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to