<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Tekst zonder opmaak Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.TekstzonderopmaakChar
{mso-style-name:"Tekst zonder opmaak Char";
mso-style-priority:99;
mso-style-link:"Tekst zonder opmaak";
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:29838245;
mso-list-type:hybrid;
mso-list-template-ids:1925621270 135462913 135462915 135462917 135462913 135462915 135462917 135462913 135462915 135462917;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:38.25pt;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:74.25pt;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:110.25pt;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:146.25pt;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:182.25pt;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:218.25pt;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:254.25pt;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:290.25pt;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:326.25pt;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l1
{mso-list-id:316304337;
mso-list-type:hybrid;
mso-list-template-ids:-638703090 135462913 135462915 135462917 135462913 135462915 135462917 135462913 135462915 135462917;}
@list l1:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL-BE" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE">I have tested both functions and as far as I can tell there is no difference between
<i>length($geometry)</i> and <i>$length</i>. I did the following test:<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:38.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">I created 3 layers (1 in EPSG:3857, 1 in EPSG:31370 and 1 in EPSG:2154)<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:38.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">In each of the files I added 1 simple line with approximately the same length.<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:38.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">To each layer I added the same label definition:
<i>concat(length($geometry),'-',$length)</i><o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:38.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">I measured the approximate length of the lines with the Measure Tool.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE">I made a print screen image that shows the results and uploaded it to Dropbox:
<a href="https://www.dropbox.com/s/plza9bwkh4wfd29/length_tests.jpg?dl=0">https://www.dropbox.com/s/plza9bwkh4wfd29/length_tests.jpg?dl=0</a><o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE">The results:<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">As expected there is a big difference between the layer in EPSG:3857 and the other 2 layers.
<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">As expected the results of the Measure Tool are very close to the results of the layers in EPSG:31370 and in EPSG:2154.<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">As expected changing the project CRS, changes the direction of the lines and their placement.
<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">But the labels always stay the same no matter what project CRS I use<o:p></o:p></span></p>
<p class="MsoPlainText" style="margin-left:36.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span lang="EN-US" style="font-family:Symbol;mso-fareast-language:NL-BE"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span lang="EN-US" style="mso-fareast-language:NL-BE">And the results for $length and length($geometry) are in all cases the same per line. So I don’t see a difference between
<i>length($geometry)</i> and <i>$length</i>.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE">I tested it both in QGIS 3.0.3 and QGIS 2.18.20 and they gave similar results.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE">I don’t think using $length solves my problem, or did I do something wrong?<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE">Michel<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US" style="mso-fareast-language:NL-BE"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="NL" style="mso-fareast-language:NL-BE">-----Oorspronkelijk bericht-----<br>
Van: Goyo [mailto:goyodiaz@gmail.com] <br>
Verzonden: dinsdag 22 mei 2018 23:37<br>
Aan: Michel Stuyts <michel.stuyts@edegem.be><br>
CC: Micha Silver <tsvibar@gmail.com>; qgis-user <qgis-user@lists.osgeo.org><br>
Onderwerp: Re: [Qgis-user] results Measure Tool vs. length()</span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">The measure tool measures elipsoidal distances (configurable in the project properties).<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">The function length(geometry) returns the length of the argument<o:p></o:p></p>
<p class="MsoPlainText">(linestring) measured in the plane.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">The function $length() returns the length of the current geometry<o:p></o:p></p>
<p class="MsoPlainText">(linestring) measured in the elipsoid and should be consistent with the measure tool (same configuration).<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">You do not want to use length(geometry) unless you are using a local projection.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">2018-05-22 11:57 GMT+02:00 Michel Stuyts <<a href="mailto:michel.stuyts@edegem.be"><span style="color:windowtext;text-decoration:none">michel.stuyts@edegem.be</span></a>>:<o:p></o:p></p>
<p class="MsoPlainText">> 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.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Michel<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> ________________________________<o:p></o:p></p>
<p class="MsoPlainText">> Van: Micha Silver [tsvibar@gmail.com]<o:p></o:p></p>
<p class="MsoPlainText">> Verzonden: vrijdag 18 mei 2018 17:41<o:p></o:p></p>
<p class="MsoPlainText">> Aan: Michel Stuyts; qgis-user<o:p></o:p></p>
<p class="MsoPlainText">> Onderwerp: Re: [Qgis-user] results Measure Tool vs. length()<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> 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.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> (If you already understand the above, I apologize for restating the
<o:p></o:p></p>
<p class="MsoPlainText">> obvious...)<o:p></o:p></p>
<p class="MsoPlainText">> <span lang="EN-US"><o:p></o:p></span></p>
</div>
</body>
</html>