ST_Transform converts a geometry’s coordinates into a specified spatial reference system and returns a new geometry. It is useful when projected coordinates must become longitude and latitude for GPS-style output. section 10.5.1
Convert Tampa’s point to latitude and longitude
SELECT name, ST_AsText(ST_Transform(way, 4326)) AS coordinates FROM florida.planet_osm_point WHERE name = 'Tampa' AND place = 'city'; -- Tampa | POINT(-82.458444 27.947759499952074) section 10.5.1
Build an OpenStreetMap URL
Transform the stored point first, then extract its latitude and longitude: WITH tampa_city_point AS ( SELECT ST_Transform(way, 4326) AS coordinate FROM florida.planet_osm_point WHERE name = 'Tampa' AND place = 'city' ) SELECT 'https://www.openstreetmap.org/?mlat=' || ST_Y(coordinate) || '&mlon=' || ST_X(coordinate) AS osm_url FROM tampa_city_point; section 10.5.1
Listing 10.12 Transforming coordinates to latitude and longitude
SELECT name, ST_AsText(ST_Transform(way, 4326)) AS coordinates FROM florida.planet_osm_point WHERE name = 'Tampa' and place = 'city';
Browse the runnable query that transforms Tampa’s stored geometry to SRID 4326; the paired result shows the converted coordinates. section 10.5.1
