-1

I am looking to find multiple lat/long points (N,S,E,W) that are 100 metres from an input lat/lon point I have stored in PostGIS.

Given a latitude and longitude I'd like to find the latitude and longitude point that is 100 metres North, 100 metres South etc.

I don't have anything but the input lat/lon values stored in the database, so SELECTing from PostGIS will not work in this case.

According to @ThingumaBob, there is a way to find these points with PostGIS.

How would I do this?

0

1 Answer 1

2

To create 4 Points, one in each direction (NESW) at 100m distance to each input point, you can use ST_Project:

SELECT ip.<id_column> AS id,
       dir.arr[n+1] as direction,
       ST_AsText(ST_Project(ip.<geometry_column>::geography, 100.0, radians(90.0*n))) AS geom
FROM <input_points_table> AS ip CROSS JOIN generate_series(0, 3) AS n,
     (SELECT ARRAY['N', 'E', 'S', 'W'] AS arr) AS dir

I used generate_series to auto-increment the bearing and select the direction letter from the array.

This should return 4 points with their direction, for each point in <input_points_table>, with the respective ids from their <id_column>. It assumes your input points are georeferenced in EPSG:4326 (WGS84)!

Note: this returns the new point's geometries in WKT format (via ST_AsText(...)) so you can read their LatLng values. This doesn't save/store anything; if you want to use those geometries programmatically, you need to explain how you want them stored.

0

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