PostGIS

PostGIS adds spatial types and functions to PostgreSQL: geometry, geography, raster, topology, and geocoding. Thalassa Cloud DBaaS includes PostGIS 3.6.x for spatial queries and GIS workloads.

Check availability

SELECT name, default_version, installed_version, comment
FROM pg_available_extensions
WHERE name LIKE 'postgis%'
ORDER BY name;

You may see multiple PostGIS extensions (e.g. postgis, postgis-3, postgis_raster, postgis_topology). Enable the main extension first; others extend it.

Enable PostGIS

For standard geometry and geography support:

CREATE EXTENSION IF NOT EXISTS postgis;

Optional extensions (enable after postgis):

-- Raster support
CREATE EXTENSION IF NOT EXISTS postgis_raster;

-- Topology support
CREATE EXTENSION IF NOT EXISTS postgis_topology;

-- TIGER geocoder (US addresses)
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;

Verify installation

SELECT PostGIS_Version();

Basic usage

-- Create a table with a geometry column
CREATE TABLE places (
  id   SERIAL PRIMARY KEY,
  name TEXT,
  geom GEOMETRY(Point, 4326)
);

-- Insert a point (WGS 84)
INSERT INTO places (name, geom)
VALUES ('Amsterdam', ST_SetSRID(ST_MakePoint(4.9041, 52.3676), 4326));

-- Spatial query: points within a bounding box
SELECT name, ST_AsText(geom)
FROM places
WHERE ST_Within(geom, ST_MakeEnvelope(4.5, 52.0, 5.5, 53.0, 4326));

For full documentation, see the PostGIS documentation.