Geometry / geography woes
"nikolai.berkoff via postgis-users" <[email protected]> Tue, 09 Sep 2025 11:35:31 +0000
| Newsgroups | gmane.comp.gis.postgis |
|---|---|
| Message-ID | <oTgGbKjOYRRo4SyLxU9QRV4ulpfMptAFwLu8ZoW43ksOf7K9pJEmDNzLcV7gjqgLom12U2t8fTs73zuiJyc1nn-MddiEfnDnUAISJRl5wiE=@pm.me> |
Hi,
I work for a conservation NGO and we deal with lots of species ranges.
We have a complicated full geometry (SRID 4326) https://www.iucnredlist.org/species/22733619/139214707 that we have ST_Subdivided. We notice a large difference between the geographical distance from a point (-77 48) to the full geometry and to nearest subdiveded geometry.
Here is a toy example with two polygon geometries, one large and the other small and a point https://wktmap.com/?771d2fc9 . First the geographical distance from the point to the large geometry:
SELECT ST_Distance(ST_SetSRID(ST_MakePoint(-77, 48),4326)::geography, ST_GeomFromText('POLYGON((-81.1755551313531 46.64525933571578,-81.50518756520556 47.21802525065504,-81.6706742747649 47.82323694299835,-81.6602226284047 48.438637358868554,-81.46784223247613 49.04081439308046,-81.09452004412593 49.60598066574395,-80.54928811996326 50.110912115887594,-79.84994871352842 50.53403375725974,-79.02318022750863 50.85659915226637,-78.10377843647761 51.06386274945413,-77.13291403765557 51.14610652092342,-76.15549659681517 51.09937193283258,-75.21696581007667 50.925776760111056,-74.42324583717638 50.655006343959805,-81.12758032107652 46.593233077736336,-81.1755551313531 46.64525933571578))',4326)::geography);
st_distance
-----------------
100757.06933552
next the geographical distance from the point to the small geometry
SELECT ST_Distance(ST_SetSRID(ST_MakePoint(-77, 48),4326)::geography, ST_GeomFromText('POLYGON((-77.933927810506 48.584377886263184,-77.74471476703403 48.69534746901027,-77.69284285304693 48.71525447165988,-77.99039086603969 48.53485501013662,-77.933927810506 48.584377886263184))', 4326)::geography);
st_distance
----------------
93442.14463111
finally, showing the the small geometry is fully within the large geometry
SELECT ST_Within(ST_GeomFromText('POLYGON((-77.933927810506 48.584377886263184,-77.74471476703403 48.69534746901027,-77.69284285304693 48.71525447165988,-77.99039086603969 48.53485501013662,-77.933927810506 48.584377886263184))', 4326), ST_GeomFromText('POLYGON((-81.1755551313531 46.64525933571578,-81.50518756520556 47.21802525065504,-81.6706742747649 47.82323694299835,-81.6602226284047 48.438637358868554,-81.46784223247613 49.04081439308046,-81.09452004412593 49.60598066574395,-80.54928811996326 50.110912115887594,-79.84994871352842 50.53403375725974,-79.02318022750863 50.85659915226637,-78.10377843647761 51.06386274945413,-77.13291403765557 51.14610652092342,-76.15549659681517 51.09937193283258,-75.21696581007667 50.925776760111056,-74.42324583717638 50.655006343959805,-81.12758032107652 46.593233077736336,-81.1755551313531 46.64525933571578))',4326));
st_within
-----------
t
Why is the geographical distance to the point and the geometry increasing when we are only making the geometry bigger? Surely as the geometry gets bigger it should get nearer to the point?
Thank you very much!
signature.asc
(application/pgp-signature, 603 B)
-----BEGIN PGP SIGNATURE----- Version: ProtonMail wsC5BAEBCgBtBYJowBD1CZCP0vdACs4dP0UUAAAAAAAcACBzYWx0QG5vdGF0 aW9ucy5vcGVucGdwanMub3Jn6kfVragS3j0869qdRoe+35jbsjGkHSnt95zI 5Dlh7pwWIQTRiXkt+tp5DMsBczKP0vdACs4dPwAAk7AH/1AoXWmiFa8/PxhJ OHwAwSV0GETtvzfzo4AAfgnGtxv3qox2YThaEfHzz8CrCdzP0329E5dubn+g Fd11mlEOfPoPrWnWXVs9rsxb5HbyMvUfaszlzqiXzgLW3377fDIfhGVnsGPQ j3jXvnyelX0V4Vw4gx6iITF4oM9avycaV9zdcnVYSL3+s/SZFuGjxebzJyTm mnT+As6I2sk7UprCvhJuTL8GeTd5Dl4A1Pl8Zrs3GwmoN5L0dopEfhJ3mC2y ZwoOWxUx/HrWj/Iuuf2Rdl9eL/PuIyLAeBz/WAl8dXpDpMd7tF1p2TTC/nEA NVh6Sdpd7m73xVQGwoIE/T8BoI4= =wAv7 -----END PGP SIGNATURE-----