GeofabrikDownloader¶
- class pydriosm.downloader.GeofabrikDownloader(download_dir=None, update=False, **kwargs)[source]¶
Download OSM data from Geofabrik free download server.
- Parameters:
download_dir (str | os.PathLike | pathlib.Path | None) – name or pathname of a directory for saving downloaded data files, defaults to
None; whendownload_dir=None, downloaded data files are saved to a folder named ‘osm_data’ under the current working directory- Variables:
valid_subregion_names (set) – names of (sub)regions available on the free download server
valid_file_formats – filename extensions of the data files available
download_index – index of downloads for all available (sub)regions
continent_tables (dict) – download catalogues for each continent
region_subregion_tier (dict) – region-subregion tier
having_no_subregions (list) – all (sub)regions that have no subregions
catalogue (pandas.DataFrame) – a catalogue (index) of all available downloads (similar to
download_index)download_dir (str | None) – name or pathname of a directory for saving downloaded data files
data_pathnames (list) – list of pathnames of all downloaded data files
Examples:
>>> from pydriosm.downloader import GeofabrikDownloader >>> import os >>> gfd = GeofabrikDownloader() >>> gfd.NAME 'Geofabrik' >>> gfd.URL 'https://download.geofabrik.de/' >>> gfd.DOWNLOAD_INDEX_URL 'https://download.geofabrik.de/index-v1.json' >>> os.path.relpath(gfd.download_dir) 'osm_data\geofabrik' >>> gfd = GeofabrikDownloader(download_dir="tests/osm_data") >>> os.path.relpath(gfd.download_dir) 'tests\osm_data'
Attributes
Default download directory.
URL of the official download index.
Valid file formats.
Full name of the data resource.
Name of the free download server.
URL of the homepage to the free download server.
Methods
cdd(*sub_dir[, mkdir])Change directory to default download directory and its subdirectories or a specific file.
download_data(subregion_names, osm_file_formats)Download OSM data (in a specific format) of one (or multiple) geographic (sub)region(s).
file_exists(subregion_name, osm_file_format)Check whether a data file of a geographic (sub)region already exists locally, given its default filename.
file_exists_and_more(subregion_names, ...[, ...])Check if a requested data file already exists and compile information for downloading the data.
format_confirmation_prompt([data_name, ...])Compose a short message to be printed for confirmation.
get_catalogue([update, ...])Get a catalogue (index) of all available downloads.
get_continent_tables([update, ...])Get download catalogues for each continent.
get_default_filename(subregion_name, ...[, ...])get a default filename for a geograpic (sub)region.
get_default_pathname(subregion_name, ...[, ...])Get the default pathname of a local directory for storing a downloaded data file.
get_default_sub_path(subregion_name_, ...)Get default sub path for saving OSM data file of a geographic (sub)region.
get_download_index([update, ...])Get the official index of downloads for all available geographic (sub)regions.
get_prepacked_data(meth[, data_name, ...])Get auxiliary data (that is to be prepacked in the package).
get_raw_directory_index(url[, save_path, ...])Get a raw directory index (including download information of older file logs).
get_region_subregion_tiers([update, ...])Get region-subregion tier and all (sub)regions that have no subregions.
get_subregion_download_url(subregion_name, ...)Get a download URL of a geographic (sub)region.
get_subregion_table(url[, verbose, raise_error])Get download information of all geographic (sub)regions on a web page.
get_subregions(*subregion_name[, deep])Retrieve names of all subregions (if any) of the given geographic (sub)region(s).
get_valid_download_info(subregion_name, ...)Get information of downloading (or downloaded) data file.
get_valid_subregion_names([update, ...])Get names of all available geographic (sub)regions.
make_subregion_dirname(subregion_name_)Make the name of the directory one level up from an OSM data file of a geographic (sub)region.
print_action_prompt([data_name, verbose, ...])Print a short message showing the action as a function runs.
print_status([data_name, path_to_file, ...])Print a short message for an otherwise situation.
specify_sub_download_dir(subregion_name, ...)Specify a directory for downloading data of all subregions of a geographic (sub)region.
validate_file_format(osm_file_format[, ...])Validate an input file format of OSM data.
validate_subregion_name(subregion_name[, ...])Validate an input name of a geographic (sub)region.
verify_download_dir([download_dir, ...])Verify the pathname of the current download directory.