Index
OSM Loaders.
¶
Bases: Loader
, ABC
Abstract class for loaders.
¶
abstractmethod
Load data for a given area.
PARAMETER | DESCRIPTION |
---|---|
area |
Shapely geometry with the area of interest.
TYPE:
|
tags |
OSM tags filter.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: GeoDataFrame with the downloaded data. |
Source code in srai/loaders/osm_loaders/_base.py
¶
Bases: OSMLoader
OSMOnlineLoader.
OSM(OpenStreetMap)[1] online loader is a loader capable of downloading objects from a given area from OSM. It filters features based on OSM tags[2] in form of key:value pairs, that are used by OSM users to give meaning to geometries.
This loader is a wrapper around the osmnx
library. It uses osmnx.geometries_from_polygon
to make individual queries.
Source code in srai/loaders/osm_loaders/osm_online_loader.py
¶
Download OSM features with specified tags for a given area.
The loader first downloads all objects with tags
. It returns a GeoDataFrame containing
the geometry
column and columns for tag keys.
Some key/value pairs might be missing from the resulting GeoDataFrame,
simply because there are no such objects in the given area.
PARAMETER | DESCRIPTION |
---|---|
area |
Area for which to download objects.
TYPE:
|
tags |
A dictionary
specifying which tags to download.
The keys should be OSM tags (e.g.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: Downloaded features as a GeoDataFrame. |
Source code in srai/loaders/osm_loaders/osm_online_loader.py
¶
Bases: OSMLoader
OSMPbfLoader.
OSM(OpenStreetMap)[1] PBF(Protocolbuffer Binary Format)[2] loader is a loader capable of loading OSM features from a PBF file. It filters features based on OSM tags[3] in form of key:value pairs, that are used by OSM users to give meaning to geometries.
This loader uses PbfFileReader
from the QuackOSM
[3] library.
It utilizes the duckdb
[4] engine with spatial
[5] extension
capable of parsing an *.osm.pbf
file.
Additionally, it can download a pbf file extract for a given area using different sources.
References
PARAMETER | DESCRIPTION |
---|---|
pbf_file |
Downloaded
TYPE:
|
download_source |
Source to use when downloading PBF files.
Can be one of:
TYPE:
|
download_directory |
Directory where to save the downloaded
TYPE:
|
Source code in srai/loaders/osm_loaders/osm_pbf_loader.py
¶
Load OSM features with specified tags for a given area from an *.osm.pbf
file.
The loader will use provided *.osm.pbf
file, or download extracts
automatically. Later it will parse and filter features from files
using PbfFileReader
from QuackOSM
library. It will return a GeoDataFrame
containing the geometry
column and columns for tag keys.
Some key/value pairs might be missing from the resulting GeoDataFrame,
simply because there are no such objects in the given area.
PARAMETER | DESCRIPTION |
---|---|
area |
Area for which to download objects.
TYPE:
|
tags |
A dictionary
specifying which tags to download.
The keys should be OSM tags (e.g.
TYPE:
|
ignore_cache |
(bool, optional): Whether to ignore precalculated geoparquet files or not. Defaults to False.
TYPE:
|
explode_tags |
(bool, optional): Whether to split OSM tags into multiple columns or keep them in a single dict. Defaults to True.
TYPE:
|
keep_all_tags |
(bool, optional): Whether to keep all tags related to the element,
or return only those defined in the
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If PBF file is expected to be downloaded and provided geometries aren't shapely.geometry.Polygons. |
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: Downloaded features as a GeoDataFrame. |
Source code in srai/loaders/osm_loaders/osm_pbf_loader.py
¶
Load OSM features with specified tags for a given area and save it to geoparquet file.
PARAMETER | DESCRIPTION |
---|---|
area |
Area for which to download objects.
TYPE:
|
tags |
A dictionary
specifying which tags to download.
The keys should be OSM tags (e.g.
TYPE:
|
ignore_cache |
(bool, optional): Whether to ignore precalculated geoparquet files or not. Defaults to False.
TYPE:
|
explode_tags |
(bool, optional): Whether to split OSM tags into multiple columns or keep them in a single dict. Defaults to True.
TYPE:
|
keep_all_tags |
(bool, optional): Whether to keep all tags related to the element,
or return only those defined in the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Path
|
Path to the saved GeoParquet file.
TYPE:
|
Source code in srai/loaders/osm_loaders/osm_pbf_loader.py
OSMTileLoader(
tile_server_url,
zoom,
verbose=False,
resource_type="png",
auth_token=None,
data_collector=None,
storage_path=None,
)
¶
OSMTileLoader(
tile_server_url,
zoom,
verbose=False,
resource_type="png",
auth_token=None,
data_collector=None,
storage_path=None,
)
OSM Tile Loader.
Download raster tiles from user specified tile server, like listed in [1]. Loader finds x, y coordinates [2] for specified area and downloads tiles. Address is built with schema {tile_server_url}/{zoom}/{x}/{y}.{resource_type}
References
PARAMETER | DESCRIPTION |
---|---|
tile_server_url |
url of tile server, without z, x, y parameters
TYPE:
|
zoom |
zoom level [1]
TYPE:
|
verbose |
should print logs. Defaults to False.
TYPE:
|
resource_type |
file extension. Added to the end of url. Defaults to "png".
TYPE:
|
auth_token |
auth token. Added as access_token parameter to request. Defaults to None.
TYPE:
|
data_collector |
DataCollector object or
TYPE:
|
storage_path |
path to save data, used with SavingDataCollector. Defaults to None.
TYPE:
|
Source code in srai/loaders/osm_loaders/osm_tile_loader.py
¶
Return all tiles of region.
PARAMETER | DESCRIPTION |
---|---|
area |
Area for which to download objects.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: Pandas of tiles for each region in area transformed by DataCollector |
Source code in srai/loaders/osm_loaders/osm_tile_loader.py
¶
Download single tile from tile server. Return tile processed by DataCollector.
PARAMETER | DESCRIPTION |
---|---|
x(int) |
x tile coordinate
|
y(int) |
y tile coordinate
|
idx |
id of tile, if non created as x_y_self.zoom
TYPE:
|