I have PostGIS database, and want to extract lat, lon pairs sequence from Polygons (and MultiPolygons). As a very fresh PostGIS user, I'm able to just extract the Polygons:
SELECT st_astext("GEOMETRY"::geometry) FROM my_postgisdb;
which outputs Polygons and MultiPoligons.
How should I extract x, y pairs from these structures?
Answer
You can use ST_DumpPoints to get the points and then ST_AsLatLonText to get nicely readable coordinate output. It doesn't care if the geometries are multi* or not.
Alternatively, you could use ST_Boundary to get the polygon vertices, but you'd need to use ST_Dump
first for this to work for multipolygons too.
No comments:
Post a Comment