oe_download | R Documentation |
This function is used to download a file given a URL. It focuses on OSM
extracts with .osm.pbf
format stored by one of the providers implemented in
the package. The URL is specified through the parameter file_url
.
oe_download(
file_url,
provider = NULL,
file_basename = basename(file_url),
download_directory = oe_download_directory(),
file_size = NA,
force_download = FALSE,
max_file_size = 5e+08,
quiet = FALSE
)
file_url |
A URL pointing to a |
provider |
Which provider stores the file? If |
file_basename |
The basename of the file. The default behaviour is to
auto-generate it from the URL using |
download_directory |
Directory to store the file containing OSM data?. |
file_size |
How big is the file? Optional. |
force_download |
Should the |
max_file_size |
The maximum file size to download without asking in
interactive mode. Default: |
quiet |
Boolean. If |
This function runs several checks before actually downloading a new
file to avoid overloading the OSM providers. The first step is the
definition of the file's path associated to the input file_url
. The path
is created by pasting together the download_directory
, the name of chosen
provider (which may be inferred from the URL) and the basename()
of the
URL. For example, if file_url
is equal to
"https://download.geofabrik.de/europe/italy-latest.osm.pbf"
, and
download_directory = "/tmp"
, then the path is built as
"/tmp/geofabrik_italy-latest.osm.pbf"
. Thereafter, the function checks
the existence of that file and, if it founds it, then it returns the path.
The parameter force_download
is used to modify this behaviour. If there
is no file associated with the new path, then the function downloads a new
file using download.file()
with mode = "wb"
, and, again, it returns the
path.
A character string representing the file's path.
(its_match = oe_match("ITS Leeds", quiet = TRUE))
## Not run:
oe_download(
file_url = its_match$url,
file_size = its_match$file_size,
provider = "test",
download_directory = tempdir()
)
iow_url = oe_match("Isle of Wight")
oe_download(
file_url = iow_url$url,
file_size = iow_url$file_size,
download_directory = tempdir()
)
Sucre_url = oe_match("Sucre", provider = "bbbike")
oe_download(
file_url = Sucre_url$url,
file_size = Sucre_url$file_size,
download_directory = tempdir()
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.