pyrosm.get_data

Contents

pyrosm.get_data#

pyrosm.get_data(dataset, update=False, directory=None, headers=None, timeout=60, opener=None, progress=None)#

Get the path to a PBF data file, and download the data if needed.

Parameters:
  • dataset (str) – The name of the dataset, e.g. "helsinki" or "new york"; case is ignored, and spaces, dashes and underscores may replace each other. A name that several regions share, such as the country and the US state "georgia", takes its region in front: "europe/georgia", "usa/georgia". pyrosm.data.available lists every name by region.

  • update (bool) – Whether the PBF file should be downloaded/updated if the dataset with the same name exists in the temp.

  • directory (str (optional)) – Path to a directory where the PBF data will be downloaded, created when missing (does not apply for test data sets bundled with the package).

  • headers (dict (optional)) – Extra HTTP headers for the download, e.g. {"User-Agent": "my-app/1.0"}.

  • timeout (float | tuple) – Seconds to wait for the server, for the connect and each read, or a (connect, read) pair. Default 60.

  • opener (object (optional)) – An object with open(request, timeout=...), e.g. from urllib.request.build_opener(), that makes the requests instead of pyrosm.

  • progress (bool | callable | None) – None (default) follows pyrosm.enable_logging(), which is True unless set. True shows the download as a bar on stderr, a widget in Jupyter when ipywidgets is installed (pip install "pyrosm[notebook]"); without a terminal, only a line naming the file is printed. False shows nothing. A callable is called as progress(written, total) after each chunk, with the bytes written so far and the file size, None when the server does not give it.