GIS Data Exercises
Exploring and analyzing HGIS data with Claude Code
Make sure you have completed Step 5 of the Installation guide — you need an activated Python virtual environment with pandas, matplotlib, geopandas, and rdflib installed before working through Exercises 3–5 and Part 2. Exercises 1 and 2 do not need Python (Claude Code reads the CSVs directly).
The Dataset
We are working with canada_boundaries_temporal.gpkg, a GeoPackage containing the evolving political boundaries of Canada from 1667 to 2001. It is derived from Nicholson, Whebell, Galois, and Stavely, Territorial Evolution, 1670–2001 (Borealis, CC BY-NC 4.0), originally published as part of the Historical Atlas of Canada Online Learning Project. It includes:
| Table | Rows | Description |
|---|---|---|
boundaries_poly |
815 | Territorial polygons with sovereignty, temporal range |
boundary_changes |
69 | Historical events (treaties, acts) that changed boundaries |
boundaries_arc |
1,387 | Boundary line segments |
lakes |
125 | Major lakes |
rivers |
527 | Major rivers |
shoreline |
1,275 | Coastal segments |
CSV extracts of the two key attribute tables (boundaries_poly.csv and boundary_changes.csv) are also included for those who prefer working without spatial libraries.
Download the Data
Download workshop-data.zip (~64 MB) from the workshop release page.
In your claude_workshop folder, create a data/ subfolder and unzip the archive into it so the files sit at:
data/canada_boundaries_temporal.gpkgdata/boundaries_poly.csvdata/boundary_changes.csv
Exercise 1: Data Exploration
Start a Claude Code session in the workshop directory and try:
Read data/boundaries_poly.csv and give me an overview.
How many distinct territorial entities exist? How many time periods?
Then dig deeper:
Create a timeline showing how many territorial entities existed in each year.
Which sovereign power controlled the most territory names over time?
If you want Claude Code to work directly with the GeoPackage (which includes geometry), ask it to use Python with geopandas or sqlite3. The CSV files have the same attribute data but no spatial geometry.
Exercise 2: Querying the Boundary Changes
The boundary_changes table contains short descriptions of each historical event. Try asking Claude Code for specific summaries and counts:
Read data/boundary_changes.csv. Count the events per century and list them in a table.
List the treaties named in the description column, ranked by how many boundary changes each one is associated with.
Filter the rows where the description mentions Indigenous territories, treaties with First Nations, or named Indigenous groups, and list them as a table with year, description, and territories affected.
The historical interpretation of these results — why one treaty mattered more than another, what the patterns mean — is your job. Claude Code is good at retrieving and counting; it is not a substitute for the contextual knowledge you bring as a historian.
Exercise 3: Write a Script
This is where Claude Code shines — ask it to write code for you:
Write a Python script that reads boundaries_poly.csv and produces
a summary table showing, for each sovereign entity, the years they
first and last appear, and how many territorial polygons they controlled.
Claude Code will write the script, ask permission to save it, and then offer to run it. Review the output and iterate:
Good, but add a column showing the total number of years each
sovereign was present. Sort by that column descending.
Exercise 4: Visualization
Using matplotlib, create a stacked area chart showing the number of
territorial entities controlled by each sovereign power over time.
Save it as sovereignty_timeline.png.
Or, if you prefer a simpler output:
Create a text-based timeline showing major boundary events from
1667 to 1999. Format it as a markdown table I could put in a paper.
Exercise 5: Spatial Queries (Advanced)
This exercise uses the full canada_boundaries_temporal.gpkg file (74 MB), included in the workshop-data.zip download above. You will also need geopandas installed (pip install geopandas).
Using geopandas, read the boundaries_poly layer from
data/canada_boundaries_temporal.gpkg. Calculate the approximate
area of each territory in 1867 (Confederation year).
Which was largest?
Create a simple map showing Canadian territorial boundaries in 1867.
Use different colors for each sovereign. Save as confederation_1867.png.
The spatial exercises are optional. Exercises 1–4 and all of Part 2 work with the CSV files included in the workshop repository.
If You Get Stuck
If something is not working — Python is not installed, a library is missing, a command throws an error — ask Claude Code. Describe the problem in plain language: “I got this error when I tried to run the script, what’s wrong?” Troubleshooting is one of the things it does best, and learning to debug with Claude Code is just as valuable as learning to analyze data with it.
Reflection
Before we break, take a moment to consider:
- How did working with an AI assistant compare to exploring this data manually?
- What did Claude Code get right? What did it get wrong?
- What questions about the data would you not have thought to ask?
After the break, we will use what we have learned about this dataset to convert it to Linked Open Data using the LINCS application profile.