[postgis-users] Calculate the distance between a point and a line

Luca Bertoncello lucabert at lucabert.de
Wed Jan 6 07:49:39 PST 2021


Am 06.01.2021 16:45, schrieb Paul Ramsey:

> Go ST_Distance(this::geography, that::geography) then.
> DistanceSpheroid() I think still requires a spheroid definition which
> makes it clunky

Something like that:

SELECT
  name,
  admin_level,
  ST_Distance(ST_Transform('SRID=4326;POINT(50.8379138888889 
14.0007583333333)'::geography, 3857), way::geography) as dist
FROM planet_osm_roads
WHERE boundary = 'administrative'
  AND admin_level = '2'
  AND osm_id < 0
ORDER BY admin_level DESC;

?

I found the tip with cos() at 
https://postgis.net/docs/manual-3.1/ST_Distance.html

Thanks
Luca


More information about the postgis-users mailing list