GeofabrikDownloader.osm_file_exists¶
-
GeofabrikDownloader.
osm_file_exists
(subregion_name, osm_file_format, data_dir=None, update=False, verbose=False, ret_file_path=False)[source]¶ Check if a requested data file of a geographic region already exists locally.
- Parameters
subregion_name (str) – name of a geographic region (case-insensitive) available on Geofabrik’s free download server
osm_file_format (str) – OSM file format; valid values include
".osm.pbf"
,".shp.zip"
and".osm.bz2"
data_dir (str or None) – directory for saving the downloaded file(s); if None (default), use the default directory
update (bool) – whether to check on update and proceed to update the package data, defaults to
False
verbose (bool or int) – whether to print relevant information in console, defaults to
False
ret_file_path (bool) – whether to return the path to the data file (if it exists), defaults to
False
- Returns
whether requested data file exists
- Return type
bool
Examples:
>>> from pydriosm.downloader import GeofabrikDownloader >>> geofabrik_downloader = GeofabrikDownloader() >>> sr_name = 'london' >>> file_fmt = ".pbf" >>> path_to_pbf = geofabrik_downloader.osm_file_exists( ... sr_name, file_fmt, verbose=True) >>> print(path_to_pbf) True # (if the PBF data file exists) >>> path_to_pbf = geofabrik_downloader.osm_file_exists( ... sr_name, file_fmt, ret_file_path=True) >>> print(os.path.relpath(path_to_pbf)) # (if the data file exists) dat_GeoFabrik\Europe\Great Britain\England\greater-london-latest.osm.pbf