0

I am using PostgreSQL with postgis, the geometries are in UTM and stored as WKB with several shapes types (point, polygon, linestring...). Is there a way to convert the wkb to a list of points in radians or utm? without the string parsing of the shape type and each point? thanks

yoavba
  • 401
  • 2
  • 6
  • 13

1 Answers1

2

There are a whole set of geometry accessors to get exactly what you need, e.g. ST_AsText(geom) to get WKT or ST_AsGeoJSON(geom) to get GeoJSON.

To translate from UTM to degrees longitude and latitude (in that axis order), use ST_Transform(geom, 4326). I've never seen coordinates as radians, but you could first convert to WGS84 (SRID=4326), then use, e.g. ST_X(geom) * pi() / 180 for points. For other geometries, you would need to use ST_DumpPoints to get to the coordinates.

Mike T
  • 41,085
  • 18
  • 152
  • 203