Data Module¶
The data module provides functions for loading and processing geospatial data from various sources, with a focus on Overture Maps data.
Functions¶
Data Loading and Processing Module.
This module provides comprehensive functionality for loading and processing geospatial data from various sources, with specialized support for Overture Maps data. It handles data validation, coordinate reference system management, and geometric processing operations commonly needed for urban network analysis.
Functions:
| Name | Description |
|---|---|
load_overture_data |
Load data from Overture Maps using the CLI tool and optionally save to GeoJSON files. |
process_overture_segments |
Process segments from Overture Maps to be split by connectors and extract barriers. |
load_overture_data ¶
load_overture_data(
area,
types=None,
output_dir=".",
prefix="",
save_to_file=True,
return_data=True,
release=None,
connect_timeout=None,
request_timeout=None,
use_stac=True,
)
Load data from Overture Maps using the CLI tool and optionally save to GeoJSON files.
This function downloads geospatial data from Overture Maps for a specified area and data types. It can save the data to GeoJSON files and/or return it as GeoDataFrames.
Parameters:
| Name | Type | Description | Default | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
area
|
list[float] or Polygon
|
The area of interest. Can be either a bounding box as [min_lon, min_lat, max_lon, max_lat] or a Polygon geometry. |
required | ||||||||||||||||||||||||||||||||
types
|
list[str]
|
List of Overture data types to download. If None, downloads all available types. Available types:
For more information, see the Overture Maps documentation. |
None
|
||||||||||||||||||||||||||||||||
output_dir
|
str
|
Directory where GeoJSON files will be saved. |
"."
|
||||||||||||||||||||||||||||||||
prefix
|
str
|
Prefix to add to output filenames. |
""
|
||||||||||||||||||||||||||||||||
save_to_file
|
bool
|
Whether to save downloaded data to GeoJSON files. |
True
|
||||||||||||||||||||||||||||||||
return_data
|
bool
|
Whether to return the data as GeoDataFrames. |
True
|
||||||||||||||||||||||||||||||||
release
|
str
|
Overture Maps release version to use (e.g., '2024-11-13.0'). If None, uses the default release from the CLI tool. Must be a valid release from the overturemaps library's ALL_RELEASES list. |
None
|
||||||||||||||||||||||||||||||||
connect_timeout
|
float
|
Socket connection timeout in seconds. If None, uses the AWS SDK default value (typically 1 second). |
None
|
||||||||||||||||||||||||||||||||
request_timeout
|
float
|
Socket read timeout in seconds (Windows and macOS only). If None, uses the AWS SDK default value (typically 3 seconds). This option is ignored on non-Windows, non-macOS systems. |
None
|
||||||||||||||||||||||||||||||||
use_stac
|
bool
|
Whether to use Overture's STAC-geoparquet catalog to speed up queries. If False, data will be read normally without the STAC optimization. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, GeoDataFrame]
|
Dictionary mapping data type names to their corresponding GeoDataFrames. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If invalid data types are specified or if an invalid release version is provided. |
CalledProcessError
|
If the Overture Maps CLI command fails. |
See Also
process_overture_segments : Process segments from Overture Maps.
Examples:
>>> # Download building and segment data for a bounding box
>>> bbox = [-74.01, 40.70, -73.99, 40.72] # Manhattan area
>>> data = load_overture_data(bbox, types=['building', 'segment'])
>>> buildings = data['building']
>>> segments = data['segment']
>>> # Download with a specific release version
>>> data = load_overture_data(bbox, types=['building'], release='2024-11-13.0')
process_overture_segments ¶
Process segments from Overture Maps to be split by connectors and extract barriers.
This function processes road segments by splitting them at connector points and optionally generates barrier geometries based on level rules. It also performs endpoint clustering to snap nearby endpoints together.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segments_gdf
|
GeoDataFrame
|
GeoDataFrame containing road segments with LineString geometries. Expected to have 'connectors' and 'level_rules' columns. |
required |
get_barriers
|
bool
|
Whether to generate barrier geometries from level rules. |
True
|
connectors_gdf
|
GeoDataFrame
|
GeoDataFrame containing connector information. If provided, segments will be split at connector positions. |
None
|
threshold
|
float
|
Distance threshold for endpoint clustering in the same units as the CRS. |
1.0
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
Processed segments with additional columns: - 'split_from', 'split_to': Split positions if segments were split - 'length': Length of each segment - 'barrier_geometry': Passable geometry if get_barriers=True |
See Also
load_overture_data : Load data from Overture Maps.
Examples: