fix(dbt): compute geom from easting/northing in dim_location
Some checks failed
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 32s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m2s
Build and Push Docker Images / Build Kestra Init (push) Has been cancelled
Build and Push Docker Images / Build Pipeline (Meltano + dbt + Airflow) (push) Has been cancelled
Build and Push Docker Images / Trigger Portainer Update (push) Has been cancelled
Build and Push Docker Images / Build Integrator (push) Has been cancelled

Convert GIAS British National Grid coordinates (EPSG:27700) to WGS84
(EPSG:4326) directly in the dbt model. The geocode script backfills
schools missing easting/northing via Postcodes.io.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-26 21:17:08 +00:00
parent 45f3e4d9fc
commit d3e655abdb

View File

@@ -1,5 +1,6 @@
-- Mart: School location dimension — one row per URN, PostGIS-enabled -- Mart: School location dimension — one row per URN, PostGIS-enabled
-- The geom column is populated by a post-hook or the geocode script. -- Geometry derived from GIAS easting/northing (British National Grid → WGS84).
-- For schools missing easting/northing, the geocode script backfills via Postcodes.io.
select select
s.urn, s.urn,
@@ -13,7 +14,12 @@ select
s.parliamentary_constituency, s.parliamentary_constituency,
s.urban_rural, s.urban_rural,
s.easting, s.easting,
s.northing s.northing,
case
when s.easting is not null and s.northing is not null
then ST_Transform(ST_SetSRID(ST_MakePoint(s.easting, s.northing), 27700), 4326)
else null
end as geom
from {{ ref('stg_gias_establishments') }} s from {{ ref('stg_gias_establishments') }} s
where s.status = 'Open' where s.status = 'Open'
and s.postcode is not null and s.postcode is not null