DATA4207 · Data Analysis in the Social Sciences
Using Spatial Data to Understand the World
Week 9 shows how much social behaviour is a function of geography — elections, crime and public health are often patterned spatially. You learn to visualise and analyse areal data in R, judge when a map reveals more than a graph, and see how spatial structure changes interpretation. This week launches the second (spatial) group project, so the chapter is applied and map-first.
What this chapter covers
- 01Spatial data and spatial analysis: linking information to physical locations to find patterns
- 02Tobler's First Law: near things are more related than distant things
- 03Areal data and spatially defined groups (towns, LGAs, states) carrying social/economic meaning
- 04Shapefiles in R: sf::st_read() → simple feature collection with geometry, bounding box and CRS (e.g. WGS 84)
- 05Simplifying geometry (rmapshaper) and joining attribute data to a geometry column
- 06Choosing maps vs graphs; choropleth, cartogram, dot and interactive map types
- 07Limitations: data access, and the ecological fallacy (group-level truth ≠ individual-level truth)
- 08Diversity/concentration measures such as the Herfindahl-Hirschman Index (HHI); Group Project 2 begins
A concentration index for an areal unit
- +1Take each group's whole-number percentage share: 60, 30 and 10. First check they are exhaustive — 60 + 30 + 10 = 100% ✓.
- +1HHI = sum of squared percentage shares = 60² + 30² + 10² = 3600 + 900 + 100 = 4600.
- +1Classify against the thresholds: below 1,500 = diverse/competitive, 1,500-2,500 = moderate, above 2,500 = concentrated/homogeneous. HHI 4600 > 2,500, so the district is highly homogeneous (one group dominates).
- +1Caution: HHI is a group-level (areal) measure, so beware the ecological fallacy — a homogeneous district does not tell you about any individual in it. Map the index as a choropleth to reveal spatial patterns, but interpret at the area level only.
Key terms
- Spatial data
- Data tied to a specific geographic area or location, enabling spatial analysis — identifying patterns, trends and relationships by linking information to physical places.
- Tobler's First Law
- 'Everything is related to everything else, but near things are more related than distant things.' The intuition behind why spatial structure matters for social outcomes.
- Shapefile
- A common spatial file format read in R with sf::st_read(), producing a simple feature collection with a geometry column (e.g. MULTIPOLYGON), a bounding box and a coordinate reference system (CRS) such as WGS 84.
- Choropleth map
- A map that shades areal units by the value of a variable, using blocked or gradient colours (scale_fill_gradient2). The default choice when a geographic pattern adds understanding beyond a graph.
- Ecological fallacy
- The error of assuming what is true of a group is true of an individual within it — e.g. inferring an individual's risk from an area-level correlation. A central limitation of areal spatial analysis.
- Herfindahl-Hirschman Index (HHI)
- A concentration measure computed as the sum of squared percentage shares (range ~0-10,000). Higher values mean more homogeneity; common thresholds are <1,500 diverse, 1,500-2,500 moderate, >2,500 concentrated.
Using Spatial Data to Understand the World FAQ
When is a map better than a graph?
When the geographic pattern is part of the story — where a phenomenon clusters, spreads or borders — a map reveals structure a graph hides. If location does not add understanding, a graph or table is clearer. The unit teaches choosing the map type (choropleth, cartogram, dot, interactive) to match the data and the point you want a reader to see quickly.
What is the ecological fallacy and why does it matter?
It is the mistake of assuming a group-level pattern holds for individuals. 'Countries with higher coffee consumption have lower heart-disease rates' does not license 'if I drink more coffee my risk falls.' Spatial data is aggregated by area, so almost every spatial finding is at risk of this fallacy — you interpret at the area level and flag the limitation explicitly.
What do I actually do with a shapefile in R?
Read it with sf::st_read(), which returns a simple feature collection: attribute columns alongside a geometry column, with a coordinate reference system. You often simplify the polygons with rmapshaper to lighten them, join your attribute data on a matching key (name-matching is the fiddly part), and then map with geom_sf(). Group Project 2 uses exactly this pipeline, so practise it on real data.
Can AI help me with spatial data in DATA4207?
Yes, as a study aid. Sia can explain spatial concepts, the sf workflow, choropleth mapping, and measures like the HHI, and check your calculations and interpretation step by step. It teaches the method and checks your reasoning; it does not do graded work, and University of Sydney academic-integrity rules apply — confirm on Canvas whether AI is permitted for the project.
Assessment move
Go map-first this week. Load a real shapefile with sf::st_read(), inspect the geometry and CRS, join some attribute data on a name or code key, and draw a choropleth with geom_sf() — the name-matching step is where most time goes, so rehearse it. Practise choosing between a map and a graph and justifying it, and compute a concentration or diversity measure like the HHI so you can describe how homogeneous an area is. Keep the ecological fallacy front of mind: every areal finding needs the 'area level only' caveat. Because Group Project 2 (spatial, 8%) launches now and is due Week 10, treat the lab pipeline as a dry run for it, and confirm the brief and timing on Canvas.
Working through Using Spatial Data to Understand the World in DATA4207? Sia is AskSia’s AI Statistics tutor — ask any DATA4207 Using Spatial Data to Understand the World question and get a clear, step-by-step explanation grounded in how DATA4207 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.