New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ellipsoidal area ($area) consistent with Proj and PostGIS #40888
Comments
As requested on the mailing list thread, can you please check and confirm that both tests are using identical ellipsoid parameters? Can you post the semi major and semi minor axis used by both please? |
Sorry, I thought that the axis were known by the name of the Spheroid. Semi major and semi minor axis are the same. Verified with command
|
Can you check the parameters shown in QGIS project properties though? |
Screen capture added to the issue text. I also included the main points from the mail thread. |
Hi @jratike80, PostGIS uses GeographicLib for geodesic area calculation on ellipsoid/spheroid. but using SpatiaLite 4.3.0 you will get the same result of PostGIS QGIS instead uses the same algorithm used by GRASS for geodesic area calculation. The relevant part of the code is here and here. In fact, using GRAS 7.8.4 to perform the area calculation you will get a value almost identical to that obtained using QGIS (>= 3.4) one: QGIS >= 3.4: 249566957499.7546 While a bug in the squared eccentricity calc in the algorithm was fixed since QGIS 3.4 #8090 by @nyalldawson, it seems the other parts of the code are in place almost unchanged since very long time. |
Thanks a lot @agiudiceandrea! Do you think that this https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/functions_list.html#area is the best place to mention that the GRASS algorithm is used? I noticed this comment in the sources:
I will join the grass-devel list and ask what they think about the GeographicLib vs. the GRASS algorithm. |
@jratike80 Please see also these thread in grass-dev ml http://osgeo-org.1560.x6.nabble.com/area-calculations-in-several-GIS-td5379541.html and in qgis-dev ml http://osgeo-org.1560.x6.nabble.com/area-calculations-in-several-GIS-td5379541.html |
So nothing new on this area. I jumped in just because my now retired colleague from the National Land Survey of Finland asked me why he can't get accurate results from QGIS. He counts on GeographicLib and his own formulas as reference. There is one thing that I do not understand. The difference is said to be because
But GeographicLib and QGIS compute equal perimeters. Does it mean that GRASS/QGIS handles the lines differently for length and area, as geodetic lines for lenght but straight in plate-carree for areas? |
5% difference is quite considerable. Good move on raising this issue! |
The difference is not that big, only 0.654% with my test geometry. |
My bad, just had a quick glance, I just checked the first two digit. That's 10 times less. |
For reference: while there's clearly justification for the values currently calculated by QGIS, I still think this is still a valid feature request and agree that it would be preferable at some stage to switch from the grass algorithm to instead of Geographic lib for these calculations. |
@manisandro do I remember correctly that one of your derived QGIS applications is using Geographic lib? I kind of remember having seen that library in the dependencies. I'm asking just in case you have already integrated that library into QGIS. |
Anyway, in the meantime it seems GRASS devs could switch the geodesic area calculation algorithm to use the same C implementation of the GeographicLib algorithm used by PROJ: OSGeo/grass#1283. |
@elpaso Yes we use GeographicLib for KADAS |
Can you give us some more background about that choice and the advantages/disadvantages of using that library instead of the current approach? (If it is related to the issue in this ticket of course) |
For reference: #41726 |
Is this feature request resolved now that #41726 was merged in master? |
Yes, it's resolved! |
See mailing list discussion https://lists.osgeo.org/pipermail/qgis-user/2021-January/047638.html.
Main points about the test environment:
SQL query that is used as PostGIS test. The same WKT geometry was used in QGIS.
QGIS gives slightly different ellipsoidal areas than programs which are using geographiclib https://geographiclib.sourceforge.io/ for computing geodesic lengths and areas. For example PostGIS and Proj are using geographiclib
https://postgis.net/docs/ST_Area.html
https://proj.org/geodesic.html?highlight=geodesic%20calcu
It would be nice if QGIS would give same ellipsoidal areas than those two other fine open source programs under the same OSGeo umbrella. It does already give consistent results for geodesic lengths.
This link can be used as a test case
https://geographiclib.sourceforge.io/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&input=59.95688345+20.13293641%0D%0A60.47397663+26.94617837%0D%0A62.56499443+29.74782155%0D%0A68.70650340+27.45254202%0D%0A68.24937206+23.75771765%0D%0A65.27444593+25.42698984%0D%0A63.10353609+21.51545237%0D%0A61.12318104+21.40562760%0D%0A60.40477513+19.41123592%0D%0A59.95688345+20.13293641&option=Submit
Results from geographiclib
Results from QGIS 3.17-Master (with GDAL/OGR 3.3.0dev, PROJ 8.0.0)
Notice that the difference is in area. Perimeters are matching.
Implementation details do not matter but because Proj is always available and geographiclib as well then perhaps it would give some benefit to utilize https://geographiclib.sourceforge.io/1.49/classGeographicLib_1_1PolygonAreaT.html.
The text was updated successfully, but these errors were encountered: