Hello, <br>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  ?<br><br>For example, with a 3D point shapefile:<br><div style="margin-left:40px">


mylayer = qgis.utils.iface.activeLayer()<br><b>mylayer.geometryType() == QGis.Point<br>True</b><br></div>select the first object<br><div style="margin-left:40px">sel = mylayer.selectedFeatures()[0]<br>geom = sel.geometry()<br>


<b>geom.wkbType() == QGis.WKBPoint<br>False</b><br><b>geom.wkbType() == QGis.WKBPoint25D</b><br><b>True</b><br></div>but no z in<br><div style="margin-left:40px"><b>geom.asPoint()<br>(202586,89818.4)</b><br>dir(geom.asPoint())<br>


['__class__', ..., <b>'x', 'y</b>']<br>str(geom.asPoint().wellKnownText())<br>'POINT(202585.879480043950024992 89818.376070138576324098)'<br><br></div><b>But if I use ogr or Shapely (also using the GEOS library) <span lang="en"><span>to treat</span></span><span lang="en"> <span>the resulting geometry,</span></span></b><span lang="en"><span></span><span></span></span><b><span lang="en"><span> no problem with</span></span><span lang="en"><span> the z value</span></span></b><b><span lang="en"><span> </span></span>:</b><br>


<br><u>With ogr:</u><br><div style="margin-left:40px">from osgeo import ogr<br><b>wkb = geom.asWkb()</b>  <br>geom_ogr = ogr.CreateGeometryFromWkb(wkb)<br><b>geom_ogr.GetGeometryType() == ogr.wkbPoint25D<br>True</b><br></div>


and:<br><div style="margin-left:40px">dir(geom_ogr)<br>['AddGeometry',..., <b>'GetX', 'GetY', 'GetZ'</b>, 'Intersect',...]<br></div><div style="margin-left:40px"><b>geom_ogr.GetX(),geom_ogr.GetY(),geom_ogr.GetZ()<br>


(202585.87948004395, 89818.376070138576, 168.35000610351562)</b><br>geom_ogr.ExportToWkt()<br>'POINT (202585.879480043950025 89818.376070138576324 168.350006103515625)'<br><br></div><u>With Shapely</u>:<br><div style="margin-left:40px">


from shapely.wkb import loads<br>wkb_shap = loads(wkb)<br><b>wkb_shap.has_z<br>True</b><br></div>and<br><div style="margin-left:40px">dir(wkb_shap)<br>
['__array_interface__',...,'<b>coords</b>',...,  'wkt', '<b>x'</b>, 'xy', '<b>y</b>', '<b>z</b>']<br></div><div style="margin-left:40px"><b>list(wkb_shap.coords)<br>


[(202585.87948004395, 89818.376070138576, 168.35000610351562)]<br>wkb_shap.x,wkb_shap.y,wkb_shap.z<br>(202585.87948004395, 89818.376070138576, 168.35000610351562)</b><br># but no z in WKT.<br>wkb_shap.wkt<br>'POINT (202585.8794800439500250 89818.3760701385763241)'<br>


<br></div><span lang="en"><span>Therefore</span><span>, the z value</span> <span>is  present</span> <span>in the geometry</span> <span>obtained with</span> <span>PyQGI</span></span><span lang="en"><span>S and it </span><span>should be possible</span></span><span></span><span> to </span><span lang="en"><span>to extract the z value. B</span></span><span lang="en"><span>ut it</span> <span>is beyond my</span> <span>skill</span></span><span>s </span><span lang="en"><span></span><span>because the qgis module</span> is <span>compiled</span> (<span>qgis.so)<br>


<br></span></span><span lang="en"><span>Thanks in advance</span></span><br>