Help creating "corridors"
Luca Bertoncello
lucabert at lucabert.de
Sat Feb 8 06:15:37 PST 2025
Am 08.02.2025 um 14:11 schrieb Luca Bertoncello:
Hi again
> Now my problem is to create these "corridors", so let's say 20 km left
> and 20 km right of the lines.
> In other words, I need to convert my lines in polygons, then export them
> as GeoJSON.
>
> And now the very question: how can I create these polygons?
Maybe I got something...
So I create two tables:
CREATE TABLE gafor_points
(
gafor int,
position int,
coords geography(POINT)
);
CREATE TABLE gafor_routes
(
gafor int,
route geometry
);
In the first table I inserted the data I drawed with my simple
Javascript script (see last message).
Then I converted them to the geometries:
INSERT INTO gafor_routes (SELECT gafor, ST_MakeLine(coords::geometry)
from gafor_points group by gafor);
and then I create the corridors (example for GAFOR 10):
SELECT gafor, ST_AsGeoJSON(ST_Buffer(route, 0.2, 'endcap=square
join=bevel')) from gafor_routes where gafor = 10;
Now my question: as I said, I'd like to have the corridor 20km left and
20km right of the line.
I got it with the query, usind "0.2" as distance by ST_Buffer, but I got
this value by "try and cry".
Reading the docs, the distance for ST_Buffer is:
------
For geometry, the distance is specified in the units of the Spatial
Reference System of the geometry. For geography, the distance is
specified in meters.
------
Since I use geometry for my route, the unit is the Spatial Reference
System of the geometry.
With the query:
SELECT ST_SRID(route) from gafor_routes where gafor = 10;
I see, the system is 4326.
Now the very big question: how to convert meters in "unit of the Spatial
Reference System"?
I searched for that, but I didn't found the answer...
Thanks a lot for your help!
Luca Bertoncello
(lucabert at lucabert.de)
More information about the postgis-users
mailing list