Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2023 01:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Querying amenities in Greater Victoria using OSM
import osmnx as ox
import matplotlib.pyplot as plt
from pathlib import Path
("bank", {"amenity": "bank"}),
("bar", {"amenity": ["bar", "pub"]}),
("coffee shop", {"amenity": "cafe", "cuisine": "coffee_shop"}),
"greater victoria public library",
{"operator": "Greater Victoria Public Library"},
("medical clinic", {"amenity": "clinic"}),
("school", {"amenity": "school"}),
"shop": ["supermarket", "greengrocer", "convenience"],
"name": ["Walmart", "Wholesale Club"],
COL_REGEX = r"^(name|brand|geometry|(addr:\w+))$"
if __name__ == "__main__":
data_dir = Path("amenity_data_gva")
for amenity, query in AMENITY_QUERIES:
places = ox.geometries_from_place("Greater Victoria", query)
places = places.filter(regex=COL_REGEX)
places.to_file(data_dir / f"{amenity}.geojson", driver="GeoJSON")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment