[QGIS-Developer] Proper Way to Access Z from Point Vector Layer
C Hamilton
adenaculture at gmail.com
Tue Jan 18 07:01:02 PST 2022
Thanks,
I was looking at get() returning QgsAbstractGeometry not realizing that
this abstract geometry was really the QgsPoint.
Best wishes,
Calvin
On Tue, Jan 18, 2022 at 2:47 PM Benjamin Jakimow <
benjamin.jakimow at geo.hu-berlin.de> wrote:
> Hi Calvin,
>
> you might use
>
> feature.geometry().get().z()
>
> Am 18/01/2022 um 15:27 schrieb C Hamilton:
>
> As I iterate through a point vector layer I get each feature. Normally I
> would get access to the coordinate with
> pt = feature.geometry().asPoint()
> Unfortunately, this is a QgsPointXY and not a QgsPoint and I need to have
> access to the Z attribute. There is no function to return a QgsPoint that
> includes the Z and M values.
>
> If I do feature.geometry().get() there are member functions such
> as addZValue(), dropZValue (), but there is no getZValue().
>
> There is a function called vertexAt(QgsVertexId id) which returns a
> QgsPoint, but the documentation is very unclear on how to actually use
> this. What really is QgsVertexId and how should it be constructed?
> Alternatively there is vertices() or vertices_begin () which are iterators
> that potentially could be used.
>
> This all seems awkward and not documented well. What is the best way to
> get a QgsPoint from a point feature which is coming from a processing
> script like this?
>
> iterator = source.getFeatures()
> for cnt, feature in enumerate(iterator):
>
> Thanks,
>
> Calvin
>
> _______________________________________________
> QGIS-Developer mailing listQGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> --
> Benjamin Jakimow, Doctoral Researcher
> Earth Observation Lab | Geography Department | Humboldt-Universität zu Berlin
>
> e-mail: benjamin.jakimow at geo.hu-berlin.de
>
> phone: +49 (0) 30 2093 6846
> mobile: +49 (0) 157 5656 8477
> fax: +49 (0) 30 2093 6848
> mail: Unter den Linden 6 | 10099 Berlin | Germany
> room: 2'211
> web: https://hu-berlin.de/eo-lab
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220118/48573167/attachment.html>
More information about the QGIS-Developer
mailing list