<div dir="ltr"><div>This is very interesting, but from a practical point of view the problems around doing intersections on the spheroid are not to do with the difficulty of calculating spheroidal intersection points, but the difficulty in programming things that are relatively simple in cartesian (R2) space in spherical space (S2), like "is this point in this ring", because the question of "what does this ring enclose" is quite different in S2 than in R2. IE, the complexity of the problem does not reside in the spheroidal geometry but in the spherical topology. Which is not to say that it cannot be done, Google S2 has done a number of constructive geometry functions in spherical space, but it's not just a matter of getting the right intersection points.<br></div><div><br></div><div>I would be interested in direct comparisons between spheroidal and spherical intersection, rather than comparisons with "whatever the heck these tools use under the covers", which your survey shows is "quite a wide variety of approaches". <br></div><div><br></div><div>Unfortunately although PostGIS has spherical intersection internally (hilariously, I calculate it here [1] but never even let it out of the function) it is not exposed to the end user. You could use Google S2 [2] to generate spherical intersection points though, and compare those to spheroidal. <br></div><div><br></div><div>The reason I ask is because comparison of spherical and spheroidal *distances* never yield particularly large differences, always under 1%. Now, spherical distances are not *right*, but they are also *not that wrong* which is presumably why tools like S2 have eschewed finding spheroidal intersections. Under the covers you'll find that the PostGIS distance functions use spherical calculations to find the two points that are closest between two geometries, and only then calculate the spheroidal distance between those points.</div><div><br></div><div>Thanks for sharing your research,</div><div>Paul<br></div><div><br></div><div>[1] <a href="https://github.com/postgis/postgis/blob/main/liblwgeom/lwgeodetic.c#L3596">https://github.com/postgis/postgis/blob/main/liblwgeom/lwgeodetic.c#L3596</a><br>[2] <a href="http://s2geometry.io/">http://s2geometry.io/</a></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 27, 2021 at 9:34 AM José Carlos Martínez <<a href="mailto:jomarlla@cgf.upv.es">jomarlla@cgf.upv.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi list,<br>
<br>
I want to share our last research about gemetric operations on the <br>
spheroid [1]<br>
<br>
Considering two segments defined by 2 points each one over the spheroid.<br>
We want to get the intersection point defined by these two segments.<br>
<br>
Several points to note:<br>
1.- We could not find any software (Oracle Spatial, ArcGIS, PostGIS, <br>
Google Apis) that performs this calculation on the ellipsoid: some use <br>
projected CRS, others just use a local sphere.<br>
2.- The error comitted by these software is unknown.  And I go further, <br>
these unknown errors could be greater than the cartographic precision of <br>
my geo data? If so, all my geo spatial analysis could be wrong.<br>
3.- We designed a new algorithm of fast convergence working on the <br>
spheroid. We can get the exact intersection point, therefore we can <br>
asses the error from the current software solutions.<br>
4.- Example: working with segments around 50km length, the error is <br>
around 3 meters (PostGIS, ArcGIS). Table 4 from paper [2] shows the <br>
large error commited by Oracle Spatial, ArcGIS, and even PostGIS with <br>
local projected CRS (st_intersection with geography).<br>
5.- This proposed algorithm is implemented as a test in PostGIS, Java <br>
and Maxima.<br>
<br>
<br>
Finally, mention that, in a normal computer, about 20,000 intersections <br>
per second have been obtained. Perhaps, now is the time to migrate <br>
certain geospatial libraries such as JTS (GEOS), GDAL, etc. so that they <br>
carry out the calculations in full on the ellipsoid and thus be able to <br>
forget about the projected CRS, and leave them purely for aesthetic <br>
purposes.<br>
<br>
I will be proud of helping the PostGIS or the JTS team to incorporate <br>
these geometric operations on the ellipsoid (could be the first spatial <br>
BDD or geospatial library to do that).<br>
<br>
<br>
Cheers,<br>
<br>
José<br>
<br>
<br>
All the information, source code, etc. here.<br>
[1] <br>
<a href="https://cartosig.webs.upv.es/2021/07/27/geodesic-intersection-proposed-algorithm-and-error-assessment-of-current-software/" rel="noreferrer" target="_blank">https://cartosig.webs.upv.es/2021/07/27/geodesic-intersection-proposed-algorithm-and-error-assessment-of-current-software/</a><br>
<br>
[2] <a href="https://www.mdpi.com/2076-3417/11/11/5129" rel="noreferrer" target="_blank">https://www.mdpi.com/2076-3417/11/11/5129</a><br>
<br>
Martínez-Llario JC, Baselga S, Coll E. Accurate Algorithms for Spatial <br>
Operations on the Spheroid in a Spatial Database Management System. <br>
Applied Sciences. 2021; 11(11):5129. <a href="https://doi.org/10.3390/app11115129" rel="noreferrer" target="_blank">https://doi.org/10.3390/app11115129</a><br>
<br>
[3] <a href="https://link.springer.com/article/10.1007/s11200-017-1020-z" rel="noreferrer" target="_blank">https://link.springer.com/article/10.1007/s11200-017-1020-z</a><br>
<br>
Baselga, S., Martínez-Llario, J.C. Intersection and point-to-line <br>
solutions for geodesics on the ellipsoid. Stud Geophys Geod 62, 353–363 <br>
(2018). <a href="https://doi.org/10.1007/s11200-017-1020-z" rel="noreferrer" target="_blank">https://doi.org/10.1007/s11200-017-1020-z</a><br>
<br>
[4] <a href="https://github.com/jomarlla/geodesicSpatialOperators" rel="noreferrer" target="_blank">https://github.com/jomarlla/geodesicSpatialOperators</a><br>
<br>
<br>
-- <br>
-------------------------------<br>
José Carlos Martínez Llario<br>
<a href="http://www.upv.es/ficha-personal/jomarlla" rel="noreferrer" target="_blank">http://www.upv.es/ficha-personal/jomarlla</a><br>
<a href="https://cartosig.webs.upv.es" rel="noreferrer" target="_blank">https://cartosig.webs.upv.es</a><br>
Producción Cartográfica y SIG.<br>
Dpto. Ingeniería Cartográfica.<br>
Univ. Politécnica de Valencia.<br>
-------------------------------<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>