Skip to content

Instantly share code, notes, and snippets.

@sven4all
Created May 16, 2025 07:05
Show Gist options
  • Save sven4all/2b69fc2dc08e624171235e21ce360aab to your computer and use it in GitHub Desktop.
Save sven4all/2b69fc2dc08e624171235e21ce360aab to your computer and use it in GitHub Desktop.
An example python script for how you can get data https://api.datadeelmobiliteit.nl/vehicles and filter out all data outside of a GeoJSON file.
import requests
import json
from shapely.geometry import shape, Point
# Step 1: Load Zwolle boundary GeoJSON manually
with open("zwolle.geojson") as f:
geojson = json.load(f)
# Assuming the first feature contains the polygon
zwolle_polygon = shape(geojson['features'][0]['geometry'])
# Step 2: Fetch vehicle data from the API
url = "https://api.datadeelmobiliteit.nl/vehicles" # Replace with actual URL
response = requests.get(url)
data = response.json()
vehicles = data['data']['vehicles']
# Step 3: Filter vehicles within Zwolle
vehicles_in_zwolle = []
for v in vehicles:
point = Point(v['lon'], v['lat'])
if zwolle_polygon.contains(point):
vehicles_in_zwolle.append(v)
# Step 4: Print filtered vehicles
print(json.dumps(vehicles_in_zwolle, indent=2))
requests==2.32.2
shapely==2.1.0
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment