osm_flex.download
This file is part of OSM-flex. Copyright (C) 2023 OSM-flex contributors listed in AUTHORS. OSM-flex is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. OSM-flex is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. —– downloading functions
Module Contents
Functions
|
create string with download-url from geofabrik |
|
Download a file located at an URL to a local file path |
|
Download country files with all OSM map info from the provider |
|
Download regions files with all OSM map info from the provider |
|
Download the entire planet file from the OSM server (ca. 60 GB). |
Attributes
- osm_flex.download._create_gf_download_url(iso3, file_format)[source]
create string with download-url from geofabrik
Parameters
- iso3str
ISO3 code of country to download
- file_formatstr
Format in which file should be downloaded; ESRI Shapefiles (‘shp’) or osm-Protocolbuffer Binary Format (‘pbf’)
Returns
- url: str
Geofabrik download URL for the requested country.
See also
DICT_GEOFABRIK for exceptions / special regions.
- osm_flex.download._download_file(download_url: str, filepath: pathlib.Path, overwrite: bool = True)[source]
Download a file located at an URL to a local file path
Parameters
- download_urlstr
URL of the file to download
- filepathstr or Path
Local file path to store the file
- overwritebool, optional
Overwrite existing files. If
False, the download will be skipped for existing files. Defaults toTrue.
- osm_flex.download.get_country_geofabrik(iso3, file_format='pbf', save_path=OSM_DATA_DIR, overwrite=False)[source]
Download country files with all OSM map info from the provider Geofabrik.de.
Parameters
- iso3str
ISO3 code of country to download Exceptions: Russia is divided into European and Asian part (‘RUS-E’, ‘RUS-A’), Canary Islands are ‘IC’.
- file_formatstr
Format in which file should be downloaded; options are ESRI Shapefiles (shp), which can easily be loaded into gdfs, or osm-Protocolbuffer Binary Format (pbf), which is smaller in size, but has a more complicated query syntax to load (functions are provided in the OSMFileQuery class).
- save_pathstr or pathlib.Path
Folder in which to save the file
Returns
- filepathPath
The path to the downloaded file (
save_path+ the Geofabrik filename)
See also
DICT_GEOFABRIK for exceptions / special regions.
- osm_flex.download.get_region_geofabrik(region, save_path=OSM_DATA_DIR, overwrite=False)[source]
Download regions files with all OSM map info from the provider Geofabrik.de
Parameters
- region: str
one of Africa, Antarctica, Asia, Australia-and-Oceania, Central-America, Europe, North-America, South-America
- save_pathstr or pathlib.Path
Folder in which to save the file
Returns
- filepathPath
The path to the downloaded file
- osm_flex.download.get_planet_file(save_path=Path(OSM_DATA_DIR, 'planet-latest.osm.pbf'), overwrite=False)[source]
Download the entire planet file from the OSM server (ca. 60 GB).
Parameters
- save_pathstr or pathlib.Path
The path to store the file.
Returns
- save_pathPath
The path to the downloaded file. Returned for consistency with other download functions.