Notebook
09
EngineeringModelled

Spatial Database

41-table PostGIS schema · 5 schemas · GeoAlchemy2 ORM · ISO 19115 metadata · Full DDL

41
across 5 schemas
Total tables
PostGIS
PostgreSQL + spatial
Database
EPSG:4326
WGS84 geographic
Coordinate system
ISO 19115
per table
Metadata standard

Database Schema (41 tables, 5 schemas)

survey
Geodetic and survey control data
7 tables
  • ·cors_stations
  • ·benchmarks
  • ·gcp_points
  • ·tide_gauges
  • ·lidar_blocks
  • ·orthophoto_tiles
  • ·dem_tiles
basemap
Base map layers: streets, buildings, parcels
9 tables
  • ·streets
  • ·buildings
  • ·parcels
  • ·admin_boundaries
  • ·land_use_existing
  • ·hydrology
  • ·contours
  • ·natural_features
  • ·utility_lines
planning
Planning, zoning, and statutory layers
10 tables
  • ·zoning_framework
  • ·heritage_overlay
  • ·flood_zones
  • ·setback_lines
  • ·planning_areas
  • ·growth_reserve
  • ·green_network
  • ·transport_corridors
  • ·utility_corridors
  • ·permit_applications
infrastructure
Infrastructure assets: water, power, roads
10 tables
  • ·water_supply_network
  • ·swro_facilities
  • ·pump_stations
  • ·reservoirs
  • ·power_transmission
  • ·substations
  • ·solar_farms
  • ·road_network
  • ·bridges_culverts
  • ·pipeline_route
management
Operational and management data
5 tables
  • ·permit_applications
  • ·enforcement_actions
  • ·property_transactions
  • ·valuations
  • ·maintenance_records

GeoAlchemy2 ORM Models

Python ORM models allow notebooks to read and write spatial data without raw SQL. Six key tables are modelled:

# Connect and query — example usage
from sqlalchemy.orm import Session
from geoalchemy2.functions import ST_Within
 
# All buildings within planning boundary
with Session(engine) as session:
tall = session.query(Building)
.filter(Building.height_m > 20)
.all()
 
# Upload GeoDataFrame to PostGIS
gdf.to_postgis('buildings', engine,
schema='basemap', if_exists='replace')

ISO 19115 Metadata Per Table

A helper function add_iso19115_columns() adds standard metadata columns to every table:

ColumnTypePurpose
md_identifierUUIDUnique record identifier
md_titleTEXTDataset title
md_abstractTEXTDescription
md_languageCHAR(3)ISO 639 language code
md_topic_categoryTEXTISO 19115 topic
md_date_createdDATERecord creation
md_date_modifiedDATELast modification
md_lineageTEXTData provenance
md_resolutionFLOATSpatial resolution (m)
md_access_constraintsTEXTUse limitations

Library: GeoAlchemy2 + SQLAlchemy

GeoAlchemy2 v0.14 ORM layer enables Python-native PostGIS interaction. Six key ORM classes: CorsStation, Street, Building,WaterSupplyNetwork, ZoningFramework, PermitApplication. Set DATABASE_URL environment variable to deploy all 41 tables viaBase.metadata.create_all(engine).

Your feedback on this notebook

Interactive Map

0/1000 characters

Your feedback is read by the Berbera planning team. All submissions are treated with respect.