[Qgis-user] results Measure Tool vs. length()

Michel Stuyts michel.stuyts at edegem.be
Wed May 23 06:35:27 PDT 2018


I have tested both functions and as far as I can tell there is no difference between length($geometry) and $length. I did the following test:

·         I created 3 layers (1 in EPSG:3857, 1 in EPSG:31370 and 1 in EPSG:2154)

·         In each of the files I added 1 simple line with approximately the same length.

·         To each layer I added the same label definition: concat(length($geometry),'-',$length)

·         I measured the approximate length of the lines with the Measure Tool.



I made a print screen image that shows the results and uploaded it to Dropbox: https://www.dropbox.com/s/plza9bwkh4wfd29/length_tests.jpg?dl=0



The results:

·         As expected there is a big difference between the layer in EPSG:3857 and the other 2 layers.

·         As expected the results of the Measure Tool are very close to the results of the layers in EPSG:31370 and in EPSG:2154.

·         As expected changing the project CRS, changes the direction of the lines and their placement.

·         But the labels always stay the same no matter what project CRS I use

·         And the results for $length and length($geometry) are in all cases the same per line.  So I don’t see a difference between length($geometry) and $length.



I tested it both in QGIS 3.0.3 and QGIS 2.18.20 and they gave similar results.



I don’t think using $length solves my problem, or did I do something wrong?





Michel









-----Oorspronkelijk bericht-----
Van: Goyo [mailto:goyodiaz at gmail.com]
Verzonden: dinsdag 22 mei 2018 23:37
Aan: Michel Stuyts <michel.stuyts at edegem.be>
CC: Micha Silver <tsvibar at gmail.com>; qgis-user <qgis-user at lists.osgeo.org>
Onderwerp: Re: [Qgis-user] results Measure Tool vs. length()



The measure tool measures elipsoidal distances (configurable in the project properties).



The function length(geometry) returns the length of the argument

(linestring) measured in the plane.



The function $length() returns the length of the current geometry

(linestring) measured in the elipsoid and should be consistent with the measure tool (same configuration).



You do not want to use length(geometry) unless you are using a local projection.





2018-05-22 11:57 GMT+02:00 Michel Stuyts <michel.stuyts at edegem.be<mailto:michel.stuyts at edegem.be>>:

> I understand that every projection has a distortion, but I was wondering how the QGIS Measure Tool manages to give results very close to local projections anywhere in the world no matter what project CRS is set, but the length() function can't.

>

> Michel

>

>

> ________________________________

> Van: Micha Silver [tsvibar at gmail.com]

> Verzonden: vrijdag 18 mei 2018 17:41

> Aan: Michel Stuyts; qgis-user

> Onderwerp: Re: [Qgis-user] results Measure Tool vs. length()

>

> Maybe I misunderstood your question, but you *should* expect different length, area and direction calculations when converting from one projection to another. Every projection distorts. Either distance, area, or direction, or some combination. A local projection is designed to minimize distortion for some small section of the planet. So survey measurements in that region will closely match map calculations. But trying to calculate from a layer that's projected to some other projection will always give different results.

>

> (If you already understand the above, I apologize for restating the

> obvious...)

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180523/0b18560f/attachment.html>


More information about the Qgis-user mailing list