2025-06-18
Theme: Geospatial analysis in Python
This week we’ll explore how Python reads and manipulates geospatial data.
You’ll learn:
Raster
- divides surface into regular cells
- similar to digital images
- e.g. remote sensing, elevation
Vector
- features defined by x,y coordinates
- classified into points, lines and polygons
- e.g. administrative data
Source: The True Size of Africa
Geographic CRS
- position on the Earth’s surface
- degrees
- latitude and longitude
- position relative to the equator and the prime meridian
- e.g. World Geodetic System (WGS84)
Projected CRS
- projects the surface of the earth onto a 2D plane
- metres
- x, y
- e.g. British National Grid (BNG)
Images: Dorman et al (2025)
We use Python’s GeoPandas library to read and manipulate geospatial data.
Geospatial data is read as a GeoDataFrame, a regular Pandas DataFrame with an additional .geometry column. The .geometry column contains the coordinates of each feature such as a state boundary. The attributes of each geometry (e.g. state name) are stored in other columns of the dataset.
For example, the following code uses the GeoPandas library to read an ESRI shapefile of the countries of the world, selects Nigeria and then prints out the first few rows.