[Qgis-user] get length of "custom" geometry in expression

Kristian Evers kreve at gst.dk
Mon Jul 6 00:04:23 PDT 2015


I think your problem is that length() returns the length of a text-string, and not the length of a geometry. As the geometry isn't a string, the output is 0.
As far as I can see it is not possible to do what you want with the default functions in the field calculator. With a bit of python in the function editor it should be possible.

Kristian

-----Oprindelig meddelelse-----
Fra: qgis-user-bounces at lists.osgeo.org [mailto:qgis-user-bounces at lists.osgeo.org] På vegne af Raymond Nijssen
Sendt: søndag 05. juli 2015 19:49
Til: qgis-user at lists.osgeo.org
Emne: [Qgis-user] get length of "custom" geometry in expression

Im' trying to do this in my label expression:

length($geometry)

but it always returns 0. Is there a way I can do that? I tried 
getlength() and getLength() as well, without luck.

I know there is the $length which works on the geometry right away, but 
i am performing a transformation first:

length( transform($geometry, 'EPSG:3857', 'EPSG:3006') )

Hoping anyone can help!

Raymond

_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list