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)
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).
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.
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:
- Recap last week's layouts and Atlas, then ask: what is a web map, and who is it for?
- Compare the static map (fixed, read-only, printable) with the interactive map (pan, zoom, click, measure)
- Open a new QGIS project with Sudan states and districts
- Build a custom XYZ basemap we control, to avoid OSM/CORS failures in an exported map
- Load the district population table as a CSV and join it to the districts
- Use the Field Calculator for area in m² and km², then population density per km²
- Style density with Graduated → 5 classes → Natural Breaks (Jenks)
- Clean the attribute form so popups read like a report, not a database
- Export with the qgis2web plugin using Leaflet
- Open
index.htmloffline, 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.
- A surveyor wants a grid, a scale bar, a north arrow and a printed sheet.
- A project manager wants to click a district and read its population.
- A community wants a map that works on a phone with no data plan.
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.
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:
area_sqm→$areaarea_sqKM→"area_sqm" / 1000000Pop_Density_pSqKM→"population_by_district_population_est_2020" / "area_sqKM"
The numbers off our own table — worth checking against yours:
- Abasiya (South Kordofan): 157,154.6 people, 42,313 km² → 3.71 /km²
- Abu Hamad (River Nile): 124,299.9 people, 316,676 km² → 0.39 /km²
- Abu Karinka (East Darfur): 172,250.1 people, 24,525 km² → 7.02 /km²
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:
- State Name →
adm1_name - District Name →
adm2_name - Population (2020) →
population_est_2020 - Area (km²) →
Area_sqKM - Density (people/km²) →
Pop_Density_pSqKM
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.
- Layers and Groups: untick temporary layers and the CSV table; set the district layer's popup to Inline Label; leave the basemap without a popup.
- Appearance: layers list collapsed, measure tool on (Metric), popups on hover, geolocate on, address search None — the search box calls a public geocoder, which is a quiet way to make an "offline" map phone home.
- Scale/Zoom: match project CRS, min zoom 1, max zoom 28 in the dialog; the exported page caps the map at 20 and the tile layer at 19, because the tiles simply do not exist deeper.
- What it weighs:
admin2_districts1.39 MB +sdn_states_fixed0.79 MB, zipped to 1.1 MB (webmapping_template.zip). A country-scale interactive district map for less than a phone photo. - Export: mapping library Leaflet, output to a path with no spaces (
~/outputs/webmap).
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
- 00:00 Welcome & recap — print layouts and Atlas, then why a web map
- ~07:40 Open the project — states + districts, custom XYZ basemap on
localhost:8000 - 13:00 Joins — Layer Properties → Joins on
admin2_districts - ~18:00 Field Calculator — area (
area_sqm,area_sqKM), then population density - 21:00 Attribute table — area and density columns checked
- 23:00 Graduated symbology — 5 classes, Natural Breaks (Jenks)
- 26:00 Attribute Form — clean field names and aliases
- 29:00 Plugins — qgis2web confirmed installed
- 33:00 Export to web map — Leaflet, layers list collapsed, measure on, min zoom 1
- 34:30 Export written —
qgis2web_2026_11_01-08_25_40_470697 - 37:00 Verify —
index.htmlin the browser (blank until it is served) - 39:00 Local server —
python3 -m http.serverin the export folder - 41:00 Zip —
webmapping_template.zip, 1.1 MB - 43:20 Wrap up — next week the Capstone briefing
Common Hang-ups and Fixes
- Blank page after export: the path has spaces or special characters, or
index.htmlwas separated from itsjs/anddata/folders. Export to a clean path and keep the folder intact. - A column is missing in the web map but present in QGIS: it was a virtual join. Materialise it and re-export.
- Districts on a blank background: your tile URL points at
localhost. Export with no basemap and a background colour, or ship the tiles. - 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.
- 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.
- Raw field names in the popup: the Attributes Form aliases were not set (or the export predates them). Set aliases and re-export.
- Huge, slow folder: too many layers, heavy geometry, or a raster got exported. Simplify or drop layers.
- Density off by a million:
$areais in square metres. Divide by 1,000,000 for km², and make sure the layer is projected, not in degrees. - Join gives NULLs: the join keys do not match exactly — spaces, spelling, text vs number.
- qgis2web missing from the Web menu: install the plugin and restart QGIS.
What You Should Have Now
training_webmapping_20261101.qgz— the project with a simple, web-ready layer stackdistricts_population.gpkg— districts witharea_sqm,area_sqKM, a realpopulationcolumn andPop_Density_pSqKM- A graduated district map (5 Natural Breaks classes on density)
- A clean attribute form with human-readable aliases
- A qgis2web / Leaflet folder that opens offline via
index.html - A zip you can hand to a project manager with no GIS software
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