The UrbanViable ETL is a local Python pipeline — not a background service, not a container — that runs on a developer workstation whenever the underlying open data needs refreshing. It downloads four public datasets, joins them on Spain’s census section identifier (CUSEC), normalises every scoring variable toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/danizd/urbanviable/llms.txt
Use this file to discover all available pages before exploring further.
[0, 1] across Galicia, and writes a single galicia_scouting.geojson. That file is then handed to Tippecanoe, which converts it into an MBTiles binary that TileServer GL can serve directly. The entire workflow produces one deployable artefact and leaves no moving parts on the server.
Pipeline at a glance
The four stages map cleanly onto the three scripts inetl/:
| Stage | Step | Script / tool | Output |
|---|---|---|---|
| Extract | 1 — Download raw sources | download_data.py | Raw files under etl/data/ |
| Transform | 2 — Load, join, normalise | process_data.py | galicia_scouting.geojson |
| Tile | 3 — Generate vector tiles | generate_tiles.sh + Tippecanoe | galicia_scouting.mbtiles |
| Deploy | 4 — Upload to server | scp (manual) | Live map update |
etl/data/renta.csv and re-run steps 2–4 without touching the OSM or Catastro files.
Directory layout
The
etl/data/ tree is .gitignored. Raw data files (especially the OSM PBF at ~200 MB and Catastro ZIPs) are never committed to the repository.Python dependencies
Install the Python requirements before running any ETL script:| Package | Min version | Role |
|---|---|---|
geopandas | >=0.14 | Read/write Shapefiles and GeoJSON, spatial joins |
pandas | >=2.0 | CSV parsing, joins, aggregations |
numpy | >=1.26 | Log normalisation (np.log1p) |
pyrosm | >=0.6 | OSM PBF parsing; installs osmium as a dependency |
pyproj | >=3.6 | CRS transformations (EPSG:25829/25830 → 4326) |
shapely | >=2.0 | Geometry predicates for spatial joins |
openpyxl | >=3.1 | Fallback if INE Atlas de Renta is distributed as .xlsx |
requests | >=2.31 | HTTP downloads in download_data.py |
Installing Tippecanoe
Tippecanoe is a standalone CLI tool — it is not a Python package and is not listed inrequirements.txt. Install it separately on the workstation where the ETL runs:
The ETL runs on your workstation, not on the server
The production server only serves the.mbtiles file via TileServer GL. It holds no Python runtime, no GeoPandas, and no Tippecanoe. After running the ETL locally you upload two files:
Output contract: the 11-column GeoJSON
process_data.py guarantees that galicia_scouting.geojson always contains exactly these columns — this is the contract between the ETL and the MapViewer frontend:
| Column | Type | Source | Use |
|---|---|---|---|
cusec | string | CNIG Secciones Censales | Section identifier |
NMUN | string | CNIG Secciones Censales | Tooltip (municipality name) |
renta_norm | float [0,1] | INE Atlas de Renta | GPU scoring slider |
renta_abs | integer | INE Atlas de Renta | Tooltip (€) |
densidad_norm | float [0,1] | Padrón / Shapefile | GPU scoring slider |
jovenes_norm | float [0,1] | IGE población | GPU scoring slider |
mayores_norm | float [0,1] | IGE población | GPU scoring slider |
poblacion_abs | integer | Padrón / Shapefile | Tooltip (inhabitants) |
actividad_norm | float [0,1] | OSM (log-normalised) | GPU scoring slider |
actividad_abs | integer | OSM | Tooltip (establishments) |
uso_comercial_norm | float [0,1] | Catastro | GPU scoring slider |
antiguedad_norm | float [0,1] | Catastro | GPU scoring slider |
_norm columns are guaranteed to lie in [0, 1] — enforced by validate_output() before the file is written. Missing source data causes the affected columns to fall back to 0.0 rather than crashing the pipeline.
Related pages
Data Sources
Where each dataset comes from, how it is structured, and the quirks to watch out for before running the ETL.
Process Data
Step-by-step walkthrough of
process_data.py — loading, joining, normalising, and exporting the GeoJSON.Generate Tiles
Running
generate_tiles.sh, every Tippecanoe parameter explained, and how to deploy the resulting MBTiles.Downloading Source Files
Use
python etl/download_data.py --download-osm to fetch the Geofabrik PBF and verify all source paths before processing.