2

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?

7

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.

  • Can you give a example about how to code it? – Maurocrispin Mar 24 '18 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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