ENCN205 · GIS Component · Lab 1

Lab 1: Reading, Exploring, and Projecting Spatial Data

University of Canterbury · Te Whare Wānanga o Waitaha

Duration: 2–3 hours  ·  Format: Python (Jupyter notebook)  ·  Prerequisite: Lab 0  ·  Assessment: sign-off quiz submitted to LEARN

1Learning Objectives

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.

If 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

This lab is not complete until you have submitted your sign-off to LEARN.

Step 1 — Self-check

Before you start the quiz, make sure you can do each of these:

Step 2 — Take the sign-off quiz

  1. Download Lab1_SignOff.html from LEARN and open it in your web browser.
  2. Enter your full name and University ID, then answer the 10 questions.
  3. 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.
  4. 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.

The PNG records your name, ID, score, and a timestamp inside the QR code. It's your proof of completion — show it to your tutor if they ask.

Tips and Troubleshooting

SymptomFix
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
Save your work frequently! Use Ctrl + S in JupyterLab.