Search code examples
javapostgis

Java Postgis how to convert jts to coordinates


I have coordinates in my postgis database with the format shape geometry :

"0102000000020000000000000000000000000000000000000000000000000049400000000000005440"

How can I convert it in coordinates (x,y) in Java ?


Solution

  • You can use PostGIS functions:

    SELECT path[1] AS number,
           st_x(geom),
           st_y(geom)
    FROM st_dumppoints(
            '0102000000020000000000000000000000000000000000000000000000000049400000000000005440'::geometry
         );
    
     number | st_x | st_y 
    --------+------+------
          1 |    0 |    0
          2 |   50 |   80
    (2 rows)