openstreetmap module provides utilities for retrieving geographic features from OpenStreetMap and calculating distances to amenities, natural features, and infrastructure for property valuation models.
Service Class
OpenStreetMapService
Service for retrieving and processing data from OpenStreetMap.Configuration settings for the service
Feature Retrieval
get_features()
Retrieve features from OpenStreetMap or a custom GeoDataFrame.Type of feature to retrieve. Built-in types include:
'water_bodies': Lakes, rivers, bays, reservoirs'rivers': Rivers and streams'lake': Lakes only'water': General water features'transportation': Railways, subways, light rail'airport': Airports and aerodromes'educational': Universities and colleges'parks': Parks, gardens, playgrounds'golf_courses': Golf courses'coastline': Coastlines
osm_tags in settings.Bounding box as (min_lon, min_lat, max_lon, max_lat)
Configuration dictionary with keys:
enabled(bool): Whether to retrieve this featureosm(bool): Whether to get from OSM or use custom GeoDataFramemin_area(float): Minimum area in square meters for polygonsmin_length(float): Minimum length in meters for linestop_n(int): Number of largest features to highlightosm_tags(dict, optional): Custom OSM tags for non-built-in features
Whether to use cached data if available
Custom GeoDataFrame to use instead of querying OSM. Must have a
name column.GeoDataFrame containing filtered features with:
geometry: Feature geometriesname: Feature names (cleaned and normalized)area: Area in square meters (for polygons)length: Length in meters (for lines)
{thing} (all features) and {thing}_top (top N largest).calculate_distances()
Calculate distances from parcels to features, both aggregate and specific top N features.Parcel GeoDataFrame
Features GeoDataFrame from
get_features()Type of feature (e.g.,
'water', 'park', 'transportation')DataFrame with distance columns (in meters):
dist_to_{feature_type}_any: Distance to nearest feature of this typedist_to_{feature_type}_{name}: Distance to each of the top N named features
enrich_parcels()
Get OpenStreetMap features and prepare them for spatial joins. Returns a dictionary of feature dataframes.Parcel GeoDataFrame (used to determine bounding box)
Settings dictionary with feature configurations
Dictionary of feature GeoDataFrames with keys like:
'water_bodies': All water body features'water_bodies_top': Top N largest water bodies'parks': All park features'parks_top': Top N largest parks- Similar patterns for other enabled feature types
Elevation Data (Placeholder)
get_elevation_data()
Get digital elevation model (DEM) data. Currently returns dummy data as a placeholder.Bounding box (min_lon, min_lat, max_lon, max_lat)
Resolution in meters
Tuple containing:
elevation: 2D array of elevation data(lon_range, lat_range): Coordinate ranges for the grid
calculate_elevation_stats()
Calculate elevation statistics for each parcel. Currently uses dummy elevation data.Parcel GeoDataFrame
Elevation data as a 2D array
Longitude and latitude ranges from
get_elevation_data()DataFrame containing:
avg_elevation: Average elevation for each parcelavg_slope: Average slope for each parcel
Initialization
init_service_openstreetmap()
Initialize an OpenStreetMap service with the provided settings.Configuration settings for the service
Initialized OpenStreetMap service