6

Given a point in EPSG:4326 I need to know how many degrees (approx) 1 meter is at this location using PostGIS. Feels like http://postgis.net/docs/manual-2.1/ST_Line_Interpolate_Point.html is useful here but I cannot figure it out.

Another way to phrase this question is: What is one point (X) here that would give me 1 meter back when running the following query?

  ST_Distance(
   'SRID=4326;POINT(Input point)'::geography,
   'SRID=4326;POINT(X)'::geography) AS geography_distance
   ;

I would happily accept a point in any direction.

Here is the same question but using "FME's Tester" Converting 1 meter to decimal degrees using FME

5
  • 9
    This is going to depend on direction. 1 metre N-S next to the pole is a very different number of degrees to 1 metre E-W (which could be 360 degrees if you are standing next to the pole!)
    – Spacedman
    Apr 29, 2022 at 8:16
  • True, I would be OK with any direction.
    – Sebastian
    Apr 29, 2022 at 8:20
  • I updated the question
    – Sebastian
    Apr 29, 2022 at 8:22
  • 2
    I mocked up a PL/pgSQL function of pieces of code I use to avoid costly projections and rule-of-three calculations. Takes into account a given angular direction of distance and the variance in its degree representation, or defaults to longitudinal direction. Assumes Earth is a sphere.
    – geozelot
    Apr 29, 2022 at 9:21
  • @geozelot that is brilliant!
    – t.ry
    Apr 29, 2022 at 9:37

1 Answer 1

5

You can execute the following query, you can modify coordinates in CTE start_coords :

WITH start_coords AS (SELECT 5 AS long, 40 AS lat),
start_point AS (SELECT *, ST_MakePoint(long, lat)::geography AS geog FROM start_coords)

SELECT
    sp.lat,
    sp.long,
    ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long, sp.lat + 1)::geography
    ) AS one_deg_lat_north,  -- in meters
    1 / ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long, sp.lat + 1)::geography
    ) AS one_meter_lat_north,  -- in degrees
    ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long, sp.lat - 1)::geography
    ) AS one_deg_lat_south,  -- in meters
    1 / ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long, sp.lat - 1)::geography
    ) AS one_meter_lat_south,  -- in degrees
    ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long + 1, sp.lat)::geography
    ) AS one_deg_long_east,  -- in meters
    1 / ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long + 1, sp.lat)::geography
    ) AS one_meter_long_east,  -- in degrees
    ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long - 1, sp.lat)::geography
    ) AS one_deg_long_west,  -- in meters
    1 / ST_Distance(
        sp.geog,
        ST_MakePoint(sp.long - 1, sp.lat)::geography
    ) AS one_meter_long_west  -- in degrees
FROM start_point sp
;
3
  • ST_MakePoint(sp.long, sp.lat + 1)::geography <-- This is not corresponding to 1 meter right? I do not think this solution is correct
    – Sebastian
    Apr 29, 2022 at 9:09
  • 2
    Look at the entire code, the part you mention is to compute, from the coordinates of the original point, a new geography point with an additionnal degree for the latitude. Then it compute the distance between the original point and this new point to get the number of meters for 1 degree, so 1 degree / number of meters gives you the number of degrees for 1 meter, see the SQL comments for the unit. Apr 29, 2022 at 9:14
  • Thats smart. Why did I not think of this
    – Sebastian
    Apr 29, 2022 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.