<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>Hi,</p>
    <p>QGIS is currently built on Proj version 6.3.2-1.  If the other
      libraries are using a spheroid by default, then they use a sphere
      for speed and not an ellipsoid for precision.  You can probably
      force this measurement in QGIS by creating a custom CRS with a
      spheroid rather than an ellipsoid. The other option is to use the
      python in QGIS and to force a geoid.<br>
    </p>
    <p>Nicolas   <br>
    </p>
    <div class="moz-cite-prefix">On 2021-01-05 1:33 p.m., Rahkonen Jukka
      (MML) wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:86cfcf40634a4358badcbd8f829b03fe@maanmittauslaitos.fi">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@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;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}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;}pre
        {mso-style-priority:99;
        mso-style-link:"HTML-esimuotoiltu Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        mso-fareast-language:FI;}span.HTML-esimuotoiltuChar
        {mso-style-name:"HTML-esimuotoiltu Char";
        mso-style-priority:99;
        mso-style-link:HTML-esimuotoiltu;
        font-family:Consolas;
        mso-fareast-language:EN-US;}span.Shkpostityyli22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}</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]-->
      <div class="WordSection1">
        <p class="MsoNormal">Hi,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span lang="EN-US">I suppose that PostGIS
            is using the WGS 84 ellipsoid but I am not sure where from
            the documentation I could find that information. The ST_Area
            document
            <a href="https://postgis.net/docs/ST_Area.html"
              moz-do-not-send="true">https://postgis.net/docs/ST_Area.html</a>
            says only “For geography types by default area is determined
            on a spheroid with units in square meters”. Same thing with
            Spatialite, documentation suggests just that it is “the”
            spheroid
            <a class="moz-txt-link-freetext" href="http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html">http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html</a>.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I did not notice this
            paragraph in the ST_Area document earlier “Enhanced: 2.2.0 -
            measurement on spheroid performed with GeographicLib for
            improved accuracy and robustness. Requires Proj >= 4.9.0
            to take advantage of the new feature.” So no wonder that the
            web app and PostGIS give the same results because they both
            use GeographicLib. And SpatiaLite 5.0 is using RTTopo that
            is a library that is based on LWGeom so close connection in
            there too.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">So perhaps the way to
            get identical areas from QGIS would be to make it to use
            GeographicLib as well. I have no idea if it is a realistic
            approach and worth making a feature request.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b><span
                  style="mso-fareast-language:FI">Lähettäjä:</span></b><span
                style="mso-fareast-language:FI"> Nicolas Cadieux
                <a class="moz-txt-link-rfc2396E" href="mailto:njacadieux.gitlab@gmail.com"><njacadieux.gitlab@gmail.com></a>
                <br>
                <b>Lähetetty:</b> tiistai 5. tammikuuta 2021 20.04<br>
                <b>Vastaanottaja:</b> Rahkonen Jukka (MML)
                <a class="moz-txt-link-rfc2396E" href="mailto:jukka.rahkonen@maanmittauslaitos.fi"><jukka.rahkonen@maanmittauslaitos.fi></a>;
                <a class="moz-txt-link-abbreviated" href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a><br>
                <b>Aihe:</b> Re: [Qgis-user] Confusion with ellipsoidal
                method of $area<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p>Hi,<span style="mso-fareast-language:FI"><o:p></o:p></span></p>
        <p>Your method in QGIS is sound.  Area is calculated using the
          wgs84 ellipsoid EPSG 7030. If you reproject to wgs84 zone 35N
          (I think this is close), area goes from 249566957499.7546m2 
          to 249566957499.721m2 or a difference of 0.0336 m2.  I don't
          think densification would change things much.<o:p></o:p></p>
        <p>My question is the following: You know that QGIS uses the
          WGS84 Ellipsoid.  What Ellipsoid are using used in the other
          software???  If you don't know, I would proceed until you
          figure that out.<o:p></o:p></p>
        <p>This is the currently used ellipsoid in the proj database in
          QGIS 3.16.  You can get this by typing proj -le in the OSFeo4W
          Shell.<o:p></o:p></p>
        <p><br>
              MERIT a=6378137.0      rf=298.257       MERIT 1983<br>
              SGS85 a=6378136.0      rf=298.257       Soviet Geodetic
          System 85<br>
              GRS80 a=6378137.0      rf=298.257222101 GRS 1980(IUGG,
          1980)<br>
              IAU76 a=6378140.0      rf=298.257       IAU 1976<br>
               airy a=6377563.396    rf=299.3249646   Airy 1830<br>
             APL4.9 a=6378137.0      rf=298.25        Appl. Physics.
          1965<br>
              NWL9D a=6378145.0      rf=298.25        Naval Weapons
          Lab., 1965<br>
           mod_airy a=6377340.189    b=6356034.446    Modified Airy<br>
             andrae a=6377104.43     rf=300.0         Andrae 1876 (Den.,
          Iclnd.)<br>
             danish a=6377019.2563   rf=300.0         Andrae 1876
          (Denmark, Iceland)<br>
            aust_SA a=6378160.0      rf=298.25        Australian Natl
          & S. Amer. 1969<br>
              GRS67 a=6378160.0      rf=298.2471674270 GRS 67(IUGG 1967)<br>
            GSK2011 a=6378136.5      rf=298.2564151   GSK-2011<br>
             bessel a=6377397.155    rf=299.1528128   Bessel 1841<br>
           bess_nam a=6377483.865    rf=299.1528128   Bessel 1841
          (Namibia)<br>
             clrk66 a=6378206.4      b=6356583.8      Clarke 1866<br>
             clrk80 a=6378249.145    rf=293.4663      Clarke 1880 mod.<br>
          clrk80ign a=6378249.2      rf=293.4660212936269 Clarke 1880
          (IGN).<br>
                CPM a=6375738.7      rf=334.29        Comm. des Poids et
          Mesures 1799<br>
             delmbr a=6376428.       rf=311.5         Delambre 1810
          (Belgium)<br>
            engelis a=6378136.05     rf=298.2566      Engelis 1985<br>
            evrst30 a=6377276.345    rf=300.8017      Everest 1830<br>
            evrst48 a=6377304.063    rf=300.8017      Everest 1948<br>
            evrst56 a=6377301.243    rf=300.8017      Everest 1956<br>
            evrst69 a=6377295.664    rf=300.8017      Everest 1969<br>
            evrstSS a=6377298.556    rf=300.8017      Everest (Sabah
          & Sarawak)<br>
            fschr60 a=6378166.       rf=298.3         Fischer (Mercury
          Datum) 1960<br>
           fschr60m a=6378155.       rf=298.3         Modified Fischer
          1960<br>
            fschr68 a=6378150.       rf=298.3         Fischer 1968<br>
            helmert a=6378200.       rf=298.3         Helmert 1906<br>
              hough a=6378270.0      rf=297.          Hough<br>
               intl a=6378388.0      rf=297.          International 1909
          (Hayford)<br>
              krass a=6378245.0      rf=298.3         Krassovsky, 1942<br>
              kaula a=6378163.       rf=298.24        Kaula 1961<br>
              lerch a=6378139.       rf=298.257       Lerch 1979<br>
              mprts a=6397300.       rf=191.          Maupertius 1738<br>
           new_intl a=6378157.5      b=6356772.2      New International
          1967<br>
            plessis a=6376523.       b=6355863.       Plessis 1817
          (France)<br>
               PZ90 a=6378136.0      rf=298.25784     PZ-90<br>
             SEasia a=6378155.0      b=6356773.3205   Southeast Asia<br>
            walbeck a=6376896.0      b=6355834.8467   Walbeck<br>
              WGS60 a=6378165.0      rf=298.3         WGS 60<br>
              WGS66 a=6378145.0      rf=298.25        WGS 66<br>
              WGS72 a=6378135.0      rf=298.26        WGS 72<br>
              WGS84 a=6378137.0      rf=298.257223563 WGS 84<br>
             sphere a=6370997.0      b=6370997.0      Normal Sphere
          (r=6370997)<o:p></o:p></p>
        <p>Nicolas<o:p></o:p></p>
        <p><o:p> </o:p></p>
        <div>
          <p class="MsoNormal">On 2021-01-05 11:43 a.m., Rahkonen Jukka
            (MML) wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">Hi,<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">I wonder what method
              QGIS is using when it computes ellipsoidal area with $area
              function. I made a test with this EPSG:4326 polygon:</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">POLYGON (( 20.13293641
              59.95688345, 26.94617837 60.47397663, 29.74782155
              62.56499443, 27.45254202 68.7065034, 23.75771765
              68.24937206, 25.42698984 65.27444593, 21.51545237
              63.10353609, 21.4056276 61.12318104, 19.41123592
              60.40477513, 20.13293641 59.95688345 ))</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">I checked that the CRS
              of the project and layer were both EPSG:4326. The
              ellipsoid in the Project-Settings was WGS 84 (EPSG:7030).
              The area that $area returns is</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">249566957499.7546</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">As a references I used
              PostGIS and web site
              <a
                href="https://geographiclib.sourceforge.io/scripts/geod-calc.html#area"
                moz-do-not-send="true">https://geographiclib.sourceforge.io/scripts/geod-calc.html#area</a>.
              With my test polygon they both give this result:</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">251199344354.4308</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">PostGIS returns bigger
              area. The difference is 0.654% so not huge but not
              negligible either.</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">A third test with
              SpatiaLite 5.0 gives a result that is very close to
              PostGIS (difference 0.001%).</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">251195856999.549927</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">As a conclusion I have
              decided to trust in PostGIS because it gives the same
              results than the web site
              <a
                href="https://geographiclib.sourceforge.io/scripts/geod-calc.html"
                moz-do-not-send="true">https://geographiclib.sourceforge.io/scripts/geod-calc.html</a>
              that feels scientifically sound. However, I wonder if I
              have used QGIS in a correct way or if there is anything I
              could do for getting areas to match better with PostGIS
              for example by densifying the long segments in my test
              polygon.</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">For getting testing
              easy I attach directly runnable  SQL for PostGIS and
              Spatialite (version 5.0 with RTTopo is needed) as well as
              a coordinate list for the web app.</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">PostGIS</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">select
              st_area(st_geogfromtext('POLYGON ((</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">20.13293641  
              59.95688345,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">26.94617837  
              60.47397663,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">29.74782155  
              62.56499443,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">27.45254202  
              68.70650340,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">23.75771765  
              68.24937206,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">25.42698984  
              65.27444593,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">21.51545237  
              63.10353609,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">21.40562760  
              61.12318104,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">19.41123592  
              60.40477513,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">20.13293641  
              59.95688345))') , true);</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">Spatialite</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">select
              st_area(st_geomfromtext('POLYGON ((</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">20.13293641  
              59.95688345,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">26.94617837  
              60.47397663,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">29.74782155  
              62.56499443,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">27.45254202  
              68.70650340,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">23.75771765  
              68.24937206,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">25.42698984  
              65.27444593,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">21.51545237  
              63.10353609,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">21.40562760  
              61.12318104,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">19.41123592  
              60.40477513,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">20.13293641  
              59.95688345))') ,true);</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">Web site (notice
              lat-lon order)</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">59.95688345
              20.13293641 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">60.47397663
              26.94617837 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">62.56499443
              29.74782155 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">68.70650340
              27.45254202 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">68.24937206
              23.75771765 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">65.27444593
              25.42698984 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">63.10353609
              21.51545237 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">61.12318104
              21.40562760 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">60.40477513
              19.41123592 </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">59.95688345
              20.13293641</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen- </span><o:p></o:p></p>
          <p class="MsoNormal"><span style="mso-fareast-language:FI"><br>
              <br>
              <o:p></o:p></span></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>Qgis-user mailing list<o:p></o:p></pre>
          <pre><a href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a><o:p></o:p></pre>
          <pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre>
          <pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre>
        </blockquote>
        <pre>-- <o:p></o:p></pre>
        <pre>Nicolas Cadieux<o:p></o:p></pre>
        <pre><a href="https://gitlab.com/njacadieux" moz-do-not-send="true">https://gitlab.com/njacadieux</a><o:p></o:p></pre>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Nicolas Cadieux
<a class="moz-txt-link-freetext" href="https://gitlab.com/njacadieux">https://gitlab.com/njacadieux</a></pre>
  </body>
</html>