pyrosm.geocode#
- pyrosm.geocode(query, polygon=True, base_url='https://nominatim.openstreetmap.org', user_agent=None)#
Geocode a place name to a Shapely polygon via Nominatim.
- Parameters:
query (str) – The place name to look up, e.g.
"Brighton and Hove, UK".polygon (bool) – When
True(default), return the place’s boundary polygon if Nominatim provides one; otherwise (or for point-/line-like results such as POIs and addresses) the place’s bounding-box rectangle is returned. The result is always aPolygon/MultiPolygon.base_url (str) – The Nominatim base URL. Defaults to the public server; point it at your own instance for heavy use.
user_agent (str, optional) – The
User-Agentheader sent to Nominatim. Defaults to a pyrosm string. Nominatim rejects requests without a descriptive agent.
- Returns:
The place’s boundary polygon, or its bounding-box rectangle.
- Return type:
shapely.geometry.Polygon or shapely.geometry.MultiPolygon
- Raises:
ValueError – If
queryis empty, the service cannot be reached, or no match is found.