0

There doesn't seem to be any column that represents lat-lon information for a particular node. I imported data into PostGIS using osm2pgsql. Any ideas on how to get this information?

Thanks in advance


EDIT: I got it working with this:

    SELECT ST_Y(ST_Transform(way, 4326)) AS lat, ST_X(ST_Transform(way, 4326)) AS long
FROM planet_osm_point;
codego123
  • 171
  • 2
  • 12

1 Answers1

1

There are many geometry output functions to convert a geometry to a human-readable form.

For example, using ST_AsLatLonText on a Point geometry:

SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)'));
      st_aslatlontext       
----------------------------
 2°19'29.928"S 3°14'3.243"W

Or if you need individual coordinates as floating point values, use ST_X and ST_Y for longitude and latitude, respectively.

Mike T
  • 41,085
  • 18
  • 152
  • 203
  • Thanks! I used this to get it done: SELECT ST_Y(ST_Transform(way, 4326)) AS lat, ST_X(ST_Transform(way, 4326)) AS long FROM planet_osm_point; – codego123 Apr 15 '16 at 16:01