November 2026 — Week 8 of 9

Applied Spatial Analysis Using QGIS - Low-Bandwidth Offline Web Maps

Applied Spatial Analysis Using QGIS — GIS for Surveyors (2026 Cohort) · 01 Nov 2026 · 43:30 (full session) · updated 02 Nov 2026 · YouTube (offline-safe)

Mission: The project manager has no QGIS and may have no internet. Send a map that opens offline in any browser.
Live focus: Recap print layouts and Atlas → what web mapping is and who it serves → a new project with states, districts and a custom XYZ basemap (to avoid OSM/CORS failures) → join the district population CSV → Field Calculator for area (m²/km²) and population density → Graduated with 5 Natural Breaks (Jenks) classes → clean aliases in the Attribute Form → export with qgis2web / Leaflet → test popups offline → zip the folder.
Data: sdn_states_fixed, admin2_districts (189 districts, UTM 36N), population_by_district.csv (2020), custom XYZ basemap on a local tile server  |  Deliverable: A zipped qgis2web folder — open index.html anywhere, no install (Project 5B).
Corrections, 02 Nov 2026. Checking this post against the class project file and the exported folder: four statements were wrong or too generous. The exported web map does lose the joined population column (it did in our own export), the basemap we used is a local tile server that will not exist on the recipient's machine, the field names below were idealised rather than the ones we actually created, and the timings now match the full 43:30 upload. The two failures are now their own section — they are worth more to you than the success.

Week 7 ended with paper: a 300 DPI PDF, one survey sheet per district. Paper answers a client. But the project manager does not have QGIS, cannot install it, and may not have internet. The analysis is useless to them unless it travels as something they can open. This week the map becomes a folder — HTML, CSS, JavaScript and data — that opens in any browser with a double-click.

Bilingual session. The theory and the audience discussion are in Arabic; the live QGIS demo is in English. The chapter list below marks the switch.

Why Week 8 Exists

Weeks 1–7 built analysis and put it on paper. This week the same analysis becomes something a non-GIS colleague can use: pan, zoom, click a district, read its population. The plan, live on screen:

  1. Recap last week's layouts and Atlas, then ask: what is a web map, and who is it for?
  2. Compare the static map (fixed, read-only, printable) with the interactive map (pan, zoom, click, measure)
  3. Open a new QGIS project with Sudan states and districts
  4. Build a custom XYZ basemap we control, to avoid OSM/CORS failures in an exported map
  5. Load the district population table as a CSV and join it to the districts
  6. Use the Field Calculator for area in m² and km², then population density per km²
  7. Style density with Graduated → 5 classes → Natural Breaks (Jenks)
  8. Clean the attribute form so popups read like a report, not a database
  9. Export with the qgis2web plugin using Leaflet
  10. Open index.html offline, click a district, read its numbers, zip the folder and hand it over

1) What Is a Web Map?

A static map is a picture. A web map is a small application: it pans, zooms, measures, and shows the attributes behind a feature when you click it. That difference is not decoration — it changes who can use the work.

Under the hood every web map is built from the same three languages as every website: HTML for structure, CSS for appearance, JavaScript for behaviour. You do not need to learn them for this week. qgis2web writes them from your QGIS project. The point is to know what you are shipping: a self-contained folder, not a link that dies when the internet does.

2) A Project and a Basemap You Control

We started a new project (training_webmapping_20261101.qgz) and added two layers from the training data: sdn_states_fixed and admin2_districts. The districts are the layer the whole map is about — the states are context.

Then the basemap. The tempting choice is the default OpenStreetMap XYZ layer, but an exported web map that depends on OSM tiles is not offline, and it can fail with CORS or rate-limit errors when the browser opens the local file. So we created our own XYZ Tiles connection — http://localhost:8000/{z}/{x}/{y}.png, a tile server running on this machine — and kept it at the bottom of the stack.

And that is exactly where the trouble starts. Open the exported index.html and there is one tile layer in it, pointing at localhost. On my laptop the map looks finished. On yours the same folder shows correct, clickable districts floating on a blank grey field. The vector data is portable; the tiles are not. The clean answer for our conditions is to export with no basemap and a plain background colour — a district choropleth does not need imagery underneath it. If you keep OSM instead, say out loud that the basemap needs internet.

The rule for the layer stack is the same as Week 7: only publish what the viewer needs. Every extra layer makes the folder heavier and the map slower.

3) Joining the Population Table

The districts carry geometry, not population. We added population_by_district.csv as an attribute-only table (Layer → Add Delimited Text Layer, geometry = none), checked its fields (adm2_name, adm1_name, population_est_2020), and joined it to admin2_districts on the district-name key — admin2, the common field in both the layer and the table.

A join is temporary until you make it permanent. Right-click the district layer → Export → Save Features As → GeoPackage, name it districts_population.gpkg, and add it to the map. qgis2web reads fields, not join definitions — export before you publish, or the population column will be missing from the web map.

The honest check. Open the attribute table and sort by population. If half the districts are NULL, the keys do not match exactly — a trailing space, a spelling difference, or a number stored as text. Fix the key before you style anything.

4) Area and Density in the Field Calculator

Raw population flatters big districts. Density is the fair comparison, and density needs area. In the attribute table of districts_population, with editing on, the Field Calculator produced:

The numbers off our own table — worth checking against yours:

The decimals are not a mistake: these are modelled figures (WorldPop 2020), not a census count. Say so before someone asks why a district has a third of a person.

This works because the layer is in a projected CRS with metre units (UTM 36N). In EPSG:4326, $area returns square degrees and the number is meaningless. That is the Week 2 rule, still true: reproject before you measure.

5) Graduated Symbology with Natural Breaks

Symbology → Graduated, value = Pop_Density_pSqKM, colour ramp = a sequential yellow-to-red ramp, mode = Natural Breaks (Jenks), classes = 5. The breaks our data produced: 0–10 · 10–41 · 41–126 · 126–312 · 312–574. Four classes below 312 and one long tail above — that is Jenks doing its job, where equal intervals would bury everything in the bottom class.

The result shows the real contrast — Khartoum's crowded districts at the dark end, the desert districts at the light end. Five classes is enough for a district map; more make the legend unreadable and the map look busier than the data is.

6) Clean Aliases for the Popup

The field names are fine for us and ugly for the viewer. In Layer Properties → Attributes Form → Drag and Drop Designer, we built the form in reading order and set aliases:

qgis2web uses these aliases as popup headings. Ten minutes here is the difference between Pop_Density_pSqKM: 7.02 and Density (people/km²): 7.02.

7) Export with qgis2web and Leaflet

We installed the qgis2web plugin (Plugins → Manage and Install Plugins) and opened Web → qgis2web → Create Web Map.

qgis2web wrote a folder containing index.html, css/, js/, data/ and the layer files. The export log is worth reading: warnings about layer size or missing fields appear there.

8) Verify Offline, Then Zip

We opened the folder, double-clicked index.html, and the map loaded: pan, zoom, measure, layer control, and a popup on click. Then we looked at what was actually in it.

The Two Failures, Because They Are the Useful Part

1. Population was not in the popup. The exported attribute keys are adm1_name, adm2_name, area_sqm, area_sqKM and Pop_Density_pSqKM — the joined population is absent. Density survived because we wrote it into a real field with the Field Calculator; population stayed a virtual join and evaporated at export. The number the project manager actually wanted is the one that did not travel. Fix: materialise the join (right-click → Export → Save Features As → GeoPackage) or copy it into a real column, re-export, and verify by reading the exported data/*.js, not by looking at QGIS.

2. The basemap only exists on my machine. One tile layer in index.html, URL http://localhost:8000/..., empty attribution string. So the honest version of "self-contained" is: the data and the interface are portable; the tiles are not.

The test that catches both, and the one to run before you submit: copy the folder to a USB stick, open it on a different machine, turn the network off, and click three districts. If the numbers you were asked for appear, it passes.

The deliverable is the whole folder zipped, not the single HTML file — the HTML needs its js/, css/ and data/ siblings. The recipient unzips it, double-clicks index.html, and the map opens in Chrome, Firefox, Edge or Safari. No QGIS, no install, no internet.

What We Did Live — Scrub Guide

Common Hang-ups and Fixes

  1. Blank page after export: the path has spaces or special characters, or index.html was separated from its js/ and data/ folders. Export to a clean path and keep the folder intact.
  2. A column is missing in the web map but present in QGIS: it was a virtual join. Materialise it and re-export.
  3. Districts on a blank background: your tile URL points at localhost. Export with no basemap and a background colour, or ship the tiles.
  4. Basemap missing / CORS errors: the XYZ tiles need the internet or are rate-limited. Use your own tile source or export without tiles and set a background colour.
  5. Popups are empty: popup fields were not enabled for the layer, or you clicked the basemap. Set the district layer to Inline Label and re-export.
  6. Raw field names in the popup: the Attributes Form aliases were not set (or the export predates them). Set aliases and re-export.
  7. Huge, slow folder: too many layers, heavy geometry, or a raster got exported. Simplify or drop layers.
  8. Density off by a million: $area is in square metres. Divide by 1,000,000 for km², and make sure the layer is projected, not in degrees.
  9. Join gives NULLs: the join keys do not match exactly — spaces, spelling, text vs number.
  10. qgis2web missing from the Web menu: install the plugin and restart QGIS.

What You Should Have Now

Deliverable reminder: this is Project 5B — one quiz plus one practical lab, graded. Submit the zipped folder, not just a screenshot of the map.

What's Next

The final session, Sunday 8 November. The capstone briefing: five ready-made projects on the Sudan data — humanitarian logistics, flood shelter siting, clinic accessibility, road–waterway crossings, agricultural slope suitability — plus a sixth slot for a question from your own work. Every one of them ends in the same two products: a print map sheet and an offline web map, exactly what Weeks 7 and 8 built.

Next in the series: Session 9 — Capstone Briefing & Final Session, recorded live (37:22) with all six options, the submission folder and the deadline window.

The deadline is three months: Sunday 7 February 2027, 23:00, for the capstone and any quizzes or labs you still owe. Life and work happen during a semester, and a course that punishes them is not a fair course. The standard does not move with the date — same six components, same weights, same defence in front of the group.

Thank you to everyone who attended, asked the questions that stopped the class, and built along the way. Everything here runs on free and open-source software — QGIS, GDAL, the Linux desktop — and open data from OpenStreetMap, OCHA HDX, WorldPop and NASA SRTM, which is the only reason a course like this can exist at all.

Resources: Course site saltco.org · YouTube @saltcoTraining · Software QGIS (free & open source, no internet required after setup) · Previous: Week 7 — Professional Print Layouts & Atlas · Full step-by-step in LAB_GUIDE_week8_web_mapping.md.

Did I miss something? Tell me in the Q&A or open an issue — this archive is living and I will update it. — Sallah