Geometry / geography woes
nikolai.berkoff
nikolai.berkoff at pm.me
Tue Sep 9 04:35:31 PDT 2025
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!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 603 bytes
Desc: OpenPGP digital signature
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20250909/242f4908/attachment.sig>
More information about the postgis-users
mailing list