Skip to content

Commit

Permalink
Update download.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio9701 authored Jul 17, 2024
1 parent b0ba187 commit f3f7606
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions urbanpy/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)


def nominatim_osm(query: str, expected_position: "int | None" = 0) -> GeoDataFrame:
def nominatim_osm(query: str, email: str, expected_position: "int | None" = 0) -> GeoDataFrame:
"""
Download OpenStreetMaps data for a specific city.
Expand All @@ -60,9 +60,15 @@ def nominatim_osm(query: str, expected_position: "int | None" = 0) -> GeoDataFra
geometry | place_id | osm_type | osm_id | display_name | place_rank | category | type | importance | icon
MULTIPOLYGON | 235480647 | relation | 1944670.0 | Lima, Peru | 12 | boundary | administrative | 0.703484 | https://nominatim.openstreetmap.org/images/map...
"""
if email is None:
raise ValueError("Please provide an email to avoid violating Nominatim API rules.")
osm_url = "https://nominatim.openstreetmap.org/search.php"
osm_parameters = {"polygon_geojson": "1", "format": "geojson"}
osm_parameters["q"] = query
osm_parameters = {
"q": query,
"polygon_geojson": "1",
"format": "geojson",
"email": email
}

response = requests.get(osm_url, params=osm_parameters)
all_results = response.json()
Expand Down

0 comments on commit f3f7606

Please sign in to comment.