Live Book https://livebook.manning.com/book/postgis-in-action-third-edition
I have land and projects. PostGIS ticked all the boxes.
It is similar to below but unlike these, is an extension rather than part of Db proper
Windows ( part of application stackbuilder): https://postgis.net/windows_downloads/ -- (has fresh updates for PostgreSQL 11,12,13 with GEOS 3.9, GDAL 3.2, Proj 7.1.1, PostGIS 3.2)(Experimental Builds section builds on each commit)
The manual - https://postgis.net/documentation
This is running in psql. If in pgAdmin just manually reconnect to your gisdb. Example is gisdb but do for any spatial databases you have.
CREATE DATABASE gisdb;
ALTER DATABASE gisdb SET search_path=public,postgis,tiger,contrib;
\c gisdb
CREATE SCHEMA IF NOT EXISTS postgis;
CREATE SCHEMA IF NOT EXISTS contrib;
CREATE EXTENSION postgis SCHEMA postgis; -- core includes geometry / geography
CREATE EXTENSION postgis_raster SCHEMA postgis; -- raster type and functions
CREATE EXTENSION postgis_sfcgal SCHEMA postgis; -- extended support for 3D geometries
CREATE EXTENSION postgis_topology; -- topogeometry relational view of spatial data
CREATE EXTENSION fuzzystrmatch SCHEMA contrib; -- needed by tiger geocoder
CREATE EXTENSION address_standardizer SCHEMA contrib; #for standardizing addresses
CREATE EXTENSION postgis_tiger_geocoder; -- geocoding and reverse geocoding using US TIGER data
SELECT postgis_extensions_upgrade();
SELECT postgis_full_version();
screen
POSTGIS="3.1.2 3.1.2" [EXTENSION]
PGSQL="130" GEOS="3.9.0-CAPI-1.14.0" SFCGAL="1.3.8"
PROJ="7.1.1"
GDAL="GDAL 3.2.0, released 2020/10/26"
LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER
very very old way of creating a feature collection - https://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html (painful)
New way
SELECT json_build_object('type', 'FeatureCollection', 'features',
json_agg(ST_AsGeoJSON(r.*)::json) )
FROM recent_building_permits AS r;