1Learning Objectives
- Import and use core Python geospatial libraries (geopandas, matplotlib, pandas)
- Read spatial data from multiple formats (GeoPackage, Shapefile, GeoJSON, CSV)
- Inspect GeoDataFrame properties: geometry, attributes, CRS, and extent
- Understand coordinate reference systems and reproject data using
.to_crs() - Create basic choropleth maps using matplotlib
- Export spatial data to GeoPackage format
2Before You Start
You need the encn205 environment from Lab 0. If you have not done
Lab 0 yet, do it first — it installs everything this lab depends on.
Basic Python knowledge is assumed: variables, lists, loops, and functions.
To start work, open your Miniforge/Anaconda Prompt (Windows) or Terminal (macOS/Linux) and run the usual two commands:
conda activate encn205 jupyter lab
Then use the JupyterLab file browser to open Lab1_SpatialData_CRS.ipynb and
run the cells in order with Shift + Enter.
conda is not recognised, or a package fails to import, see the
Troubleshooting table in Lab0_Instructions — it covers the common setup problems.3Step-by-Step Instructions
Section 1: Environment Setup
Import geopandas, pandas, and matplotlib. Verify all libraries load without errors. If you see
an ImportError, ask your tutor for help installing the missing package.
Section 2: Understanding Geometry Types
Create Point, LineString, and Polygon objects using Shapely. Understand which geometry type represents which real-world feature. Visualise all three types side by side.
Section 3: Reading Spatial Data from Files
Load the Natural Earth world countries dataset using gpd.read_file(). This dataset
ships with geopandas so no download is needed. Plot the world map to verify the data loaded correctly.
Section 4: Inspecting GeoDataFrame Properties
Use .head(), .info(), .crs, .total_bounds,
and .geom_type to explore the dataset. Filter to New Zealand and inspect its
properties. Complete the YOUR TURN exercise.
Section 5: Creating GeoDataFrames from CSV
Create a sample borehole dataset as a pandas DataFrame with Easting/Northing columns. Convert
to a GeoDataFrame using gpd.points_from_xy(). Set the CRS to EPSG:2193 (NZTM2000).
Section 6: CRS and Reprojection
Check the CRS of your borehole data. Reproject from NZTM2000 to WGS84 using .to_crs().
Compare coordinates before and after reprojection. Calculate distances in both CRS to understand
why a projected CRS is essential for engineering measurements.
Section 7: Choropleth Mapping
Create choropleth maps using .plot(column=..., cmap=...). Experiment with different
colour maps and classification schemes. Complete the water table depth mapping exercise.
Section 8: Writing Data to GeoPackage
Save your borehole GeoDataFrame to a GeoPackage file using .to_file(). Add a second
layer (WGS84 version) to the same file. Verify by reading the data back.
4Assessment: Lab Sign-Off
Step 1 — Self-check
Before you start the quiz, make sure you can do each of these:
- Successfully loaded and inspected spatial data (show
.head(),.crs,.info()) - Reprojected data between NZTM2000 and WGS84, and can explain the difference
- Created at least two choropleth maps with appropriate colour schemes
- Saved data to GeoPackage and verified the output by reading it back
- Can answer: why must all layers share the same CRS for spatial analysis?
Step 2 — Take the sign-off quiz
- Download Lab1_SignOff.html from LEARN and open it in your web browser.
- Enter your full name and University ID, then answer the 10 questions.
- You need 8 out of 10 to pass. You can retake it as often as you like — each attempt draws a new set of questions, and every answer comes with an explanation.
- When you pass, click Download Sign-Off PNG. This saves a file called
ENCN205_Lab1_<yourID>.png.
Step 3 — Submit
Upload ENCN205_Lab1_<yourID>.png to the Lab 1 Sign-Off
submission on LEARN.
Tips and Troubleshooting
| Symptom | Fix |
|---|---|
| geopandas won't import | conda install -c conda-forge geopandas, then restart the kernel |
| Plots don't show | Add %matplotlib inline at the top of your notebook |
CRS is None |
Your data has no CRS set — use gdf.set_crs('EPSG:2193') |
| Spatial operations give empty results | Check that all layers use the same CRS |
.explore() doesn't work |
Install folium: conda install -c conda-forge folium |
Ctrl + S in JupyterLab.