Hello, Why PyQGIS (which use the GEOS library) can not extract the z coordinate of a 3D object while it recognizes that the WKB geometry is 3D ?
For example, with a 3D point shapefile: mylayer = qgis.utils.iface.activeLayer() *mylayer.geometryType() == QGis.Point True* select the first object sel = mylayer.selectedFeatures()[0] geom = sel.geometry() *geom.wkbType() == QGis.WKBPoint False* *geom.wkbType() == QGis.WKBPoint25D* *True* but no z in *geom.asPoint() (202586,89818.4)* dir(geom.asPoint()) ['__class__', ..., *'x', 'y*'] str(geom.asPoint().wellKnownText()) 'POINT(202585.879480043950024992 89818.376070138576324098)' *But if I use ogr or Shapely (also using the GEOS library) to treat the resulting geometry,** no problem with the z value** :* *With ogr:* from osgeo import ogr *wkb = geom.asWkb()* geom_ogr = ogr.CreateGeometryFromWkb(wkb) *geom_ogr.GetGeometryType() == ogr.wkbPoint25D True* and: dir(geom_ogr) ['AddGeometry',..., *'GetX', 'GetY', 'GetZ'*, 'Intersect',...] *geom_ogr.GetX(),geom_ogr.GetY(),geom_ogr.GetZ() (202585.87948004395, 89818.376070138576, 168.35000610351562)* geom_ogr.ExportToWkt() 'POINT (202585.879480043950025 89818.376070138576324 168.350006103515625)' *With Shapely*: from shapely.wkb import loads wkb_shap = loads(wkb) *wkb_shap.has_z True* and dir(wkb_shap) ['__array_interface__',...,'*coords*',..., 'wkt', '*x'*, 'xy', '*y*', '*z* '] *list(wkb_shap.coords) [(202585.87948004395, 89818.376070138576, 168.35000610351562)] wkb_shap.x,wkb_shap.y,wkb_shap.z (202585.87948004395, 89818.376070138576, 168.35000610351562)* # but no z in WKT. wkb_shap.wkt 'POINT (202585.8794800439500250 89818.3760701385763241)' Therefore, the z value is present in the geometry obtained with PyQGIS and it should be possible to to extract the z value. But it is beyond my skills because the qgis module is compiled (qgis.so) Thanks in advance
_______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
