Building Footprints RESTful API

<aside> 🚨

25.11.20025: Overture CLI not working

Issue reported here: https://github.com/OvertureMaps/overturemaps-py/issues/73

So don’t freak out if your code is suddenly not working!

</aside>

<aside> 💡

Deadline is 2025-11-27@18:00

Late submission? 10% will be removed for each day that you are late (3 days max).

It’s worth 20% of the final mark.

This is an individual assignment.

</aside>

In this assignment, you will create a RESTful API for serving building footprint data from the South Holland region in the Netherlands. You will download open geospatial data, store it efficiently in a spatial database, and create a web API to serve the data with various filtering options.

Study area

Region:

South Holland (Zuid-Holland), Netherlands

Bounding Box in EPSG:28992 (Amersfoort / RD New):

minx = 78600.0 miny = 445000.0 maxx = 85800.0 maxy = 450000.0

image.png

Instructions

<aside> 💡

This assignment must be implemented in Python. For the API, use either Flask or FastAPI, and for the backend database, use DuckDB.

</aside>

Step 1: Backend Setup

First, you will need some data and a place to store it.

Write a script 01_backend_setup.py that does the following:

  1. Sets up a local DuckDB with spatial extensions as your backend database. Name the database file buildings_database.db and make sure it is stored in the same directory as your script.
  2. Downloads from Overture all the building footprints within the bounding box of the study area. You can either use the Overture Python CLI to download the data into a GeoJSON file first and then load it into the DB, or use DuckDB to directly load the buildings into your database. Overture offers its data in lon/lat format. After download you will need to convert the geometry column from WGS84 (EPSG:4326) to the Dutch coordinate system (EPSG:28992).

IMPORTANT: You will need to flip the geometry coordinates with ST_FLIPCOORDINATES() before the transformation. You transformation will look something like this: ST_Transform(ST_FLIPCOORDINATES(geometry), 'EPSG:4326', 'EPSG:28992') AS geometry


  1. Downloads the Zuid-Holland municipality polygon boundaries from PDOK. You can use the requests library to download the file through Python. PDOK is an OGC API - features service so it offers the data in CRS84 by default but also it makes it available in the Dutch system (EPSG:28992). Make sure you download the polygons in EPSG:28992. Also make sure you download only the municipalities for Zuid-Holland and not for the whole Netherlands.
  2. Links each of the building footprints to a municipality by performing a spatial join on your tables and adding any necessary columns. You do not need to look into cases where buildings overlap with the municipality border. Keep in mind that not all of the Zuid-holland municipalities will have buildings in them.

<aside> 💡

Ensure your final table contains data in the Dutch coordinate system (EPSG: 28992), as this is a requirement for the next step.

</aside>

Step 2: API

Create a RESTful API using FastAPI (recommended) or Flask to serve your data. Your response format should be GeoJSON or JSON (as further explained below). Make sure you create the following endpoints:

1. Collections Endpoint

image.png

2. Municipality-based Endpoints