liveBook · Manning

Spatial reference system

As explained in Just Use Postgres!

A spatial reference system defines the coordinate system and spatial interpretation used to represent geographic locations and geometries.

A spatial reference system defines how coordinates represent geographic locations and how spatial operations interpret their units. In PostGIS, geometries carry an SRID identifying that system. section 10.5.1

Use these PostGIS functions to assign, convert, inspect, and compare spatial coordinates:

  • ST_SetSRID assigns SRID metadata without changing coordinate values. section 10.5.1
  • ST_Transform creates a geometry in another spatial reference system and converts its coordinates. section 10.5.1
  • ST_Distance and ST_DWithin interpret distances using the geometries’ spatial reference system units. section 10.5.1

Convert a city point to longitude and latitude

SELECT name, ST_AsText(ST_Transform(way, 4326)) AS coordinates FROM florida.planet_osm_point WHERE name = 'Tampa' AND place = 'city'; returns POINT(-82.458444 27.947759499952074). 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';

Inspect the runnable query that transforms stored coordinates into latitude-and-longitude form. section 10.5.1

How Just Use Postgres! covers it

How deep it goes
Explains SRID assignment versus coordinate transformation and demonstrates distance operations, without covering projection theory.
Examples
Demonstrates Tampa coordinates, an OpenStreetMap URL, and restaurant distances around a hotel.
What it assumes
Assumes familiarity with PostGIS geometries, SQL queries, and point data; teaches SRID assignment and transformation directly.
What you can do after
Apply via PostGIS by assigning SRIDs, transforming geometries, extracting coordinates, and filtering nearby points.
How it connects
Connects spatial reference systems with geometries, SRIDs, coordinate systems, projections, longitude, latitude, and spatial distance.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.