liveBook · Manning

ST_MakePoint

As explained in Just Use Postgres!

ST_MakePoint is a PostGIS function that constructs a point geometry from X and Y coordinates.

ST_MakePoint constructs a Point geometry from supplied X and Y coordinates. Pair it with ST_SetSRID to assign the coordinates’ spatial reference metadata before using spatial distance queries. section 10.5.1

Create a point for a known location

WITH roost_hotel AS ( SELECT ST_SetSRID( ST_MakePoint(-9178356.224987695, 3242002.0503882724), 3857) AS point ) SELECT p.name, round(ST_Distance(h.point, p.way)) AS distance_meters FROM roost_hotel AS h JOIN florida.planet_osm_point AS p ON ST_DWithin(h.point, p.way, 500) WHERE p.amenity = 'restaurant' ORDER BY distance_meters LIMIT 5; The query creates a Web Mercator point, finds restaurants within 500 units, and orders the five nearest results. section 10.5.1

How Just Use Postgres! covers it

How deep it goes
Defines X/Y construction and demonstrates SRID assignment, but does not detail coordinate transformation internals.
Examples
Uses provided hotel coordinates to locate nearby restaurants within 500 units.
What it assumes
Assumes X/Y coordinates and spatial reference identifiers, while distinguishing SRID assignment from coordinate transformation.
What you can do after
Build it from scratch and apply it in coordinate-based proximity queries.
How it connects
Connects point construction with ST_SetSRID, ST_DWithin, and ST_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.