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

Raymond Nijssen r.nijssen at terglobo.nl
Mon Jul 6 09:03:21 PDT 2015


Kristian, thanks for your explanation. I will check the function editor.

Richard, your solution would not solve my problem as I still use 
$length. But as a workaround I saved my layer in the CRS I needed and 
used the $length function in the label expression.

Regards,
Raymond

On 06-07-15 09:04, Kristian Evers wrote:
> 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
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>

-- 
Terglobo
Ampèrestraat 110
5223 CT 's-Hertogenbosch
06-25314983



More information about the Qgis-user mailing list