How to convert location data to longitude and altitude using the query of PostgreSQL?

690 views Asked by At

I am newbie to PostgreSQL and postGIS...I have a PostgreSQL database dump, which contains a series of location data.

The location data should be the longitude and altitude of some points but is stored in the sql file in a string of numbers and letters, which is odd for me. For instance:

0101000020E61000009513A7B4801F6340131CD8D0766A3BC0

How I can convert this string to longitude and altitude using the query of PostgreSQL?

1

There are 1 answers

0
corvinusz On

If you have a postgis extension and than you can cast geography-location to geometry and use ST_AsLatLonText(geometry) function.

SELECT ST_AsLatLonText
FROM (0101000020E61000009513A7B4801F6340131CD8D0766A3BC0::geometry);