UrbanAccessAnalyzer.utils¶
Geocoding and misc filesystem/text helpers.
Geocoding goes directly against the Nominatim HTTP API (no osmnx dependency):
:func:geocode for point results, :func:get_city_geometry for full place
boundary polygons via Nominatim's polygon_geojson=1 parameter.
Source: Nominatim search API, https://nominatim.org/release-docs/latest/api/Search/
geocode(q, results=1, buffer=0)
¶
Look a place up on OpenStreetMap Nominatim and return its boundary (or point), optionally buffered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Place name or address. |
required | |
results
|
int
|
Number of results to request. |
1
|
buffer
|
float
|
Buffer in metres around the result. |
0
|
Returns:
| Type | Description |
|---|---|
|
GeoDataFrame in EPSG:4326, or None if nothing was found. |
get_folder(path)
¶
Returns the directory for a given path. - If path is a file (has an extension), returns its parent folder. - If path is a folder, returns the normalized folder path. - If path is just a filename (e.g. "file.txt"), returns None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
A file or folder path. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The folder, or None for a bare file name. |
gdf_fuzzy_match(gdf, city_name, column='NAMEUNIT')
¶
The row whose name best matches city_name: an exact match after removing accents and case, else the closest
fuzzy match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
Table of places. |
required | |
city_name
|
Name to look for. |
required | |
column
|
Name column. |
'NAMEUNIT'
|
Returns:
| Type | Description |
|---|---|
|
A one-row GeoDataFrame (the best match is always returned). |