postgres location conversion

Load the DB

osm2pgsql -C 8000 --slim \ 
    --number-processes 4 -c \
    -d gis /gcc-states-latest.osm.pbf


I have an OSM Database, the data inside it is in

  • Mercator (EPSG 3857) This is the default for Maps....

But I want it as

  • WGS84 (EPSG 4326)
SELECT ST_X(geom) as "lon", ST_Y(geom) as "lat"
(SELECT  ST_Transform(ST_SetSrid(ST_MakePoint(650782133/100,270526304/100), 3857), 4326) as geom) g;

Within the OSM environment,

select ST_X(ST_Transform(ST_SetSrid(ST_MakePoint(nd.lon/100,, 3857), 4326)) as "lon",
       ST_Y(ST_Transform(ST_SetSrid(ST_MakePoint(nd.lon/100,, 3857), 4326)) as "lat",,nd.lon, ow.tags
        from public.planet_osm_ways as ow,
              public.planet_osm_nodes as nd
                where array_to_string(ow.tags, ',') like '%1737%' and
                      array_to_string(ow.tags,',') like '%way%' and
                      array[] <@ ow.nodes;