| oe_find | R Documentation |
This function takes a place name and returns the path of .pbf/.gpkg
files associated with it.
oe_find(
place,
provider = "geofabrik",
download_directory = oe_download_directory(),
download_if_missing = FALSE,
return_pbf = TRUE,
return_gpkg = TRUE,
quiet = FALSE,
...
)
place |
Description of the geographical area that should be matched with
a |
provider |
Which provider should be used to download the data? Available
providers can be browsed with |
download_directory |
Directory where the function looks for matches. |
download_if_missing |
Should we attempt to download the matched file if
it cannot be found? |
return_pbf |
Logical of length 1. If |
return_gpkg |
Logical of length 1. If |
quiet |
Boolean. If |
... |
Extra arguments that are passed to |
The matching between the existing files (saved in the directory
specified by download_directory parameter) and the input place is
performed using list.files(), setting the pattern argument equal to the
basename of the URL associated to the input place. For example, if you
specify place = "Isle of Wight", then your input is matched (via
oe_match()) with the URL of Isle of Wight. Finally, the files are
selected using a pattern equal to the basename of that URL.
If there is no file in the download_directory that can be matched with
the basename of the URL and download_if_missing is TRUE, then the
function tries to download it (geofabrik is the default provider) and
returns the path. Otherwise it stops with an error.
By default, this function returns the path of both .osm.pbf and .gpkg
files associated with the input place (if any). You can exclude one of the
two formats using the arguments return_pbf or return_gpkg to FALSE.
A character vector of length one (or two) representing the path(s) of
the .pbf/.gpkg files associated with the input place. The files are
sorted in alphabetical order, which implies that if both formats are
present in the download_directory, then the .gpkg file should be
returned first.
# Copy the ITS file to tempdir() to make sure that the examples do not
# require internet connection. You can skip the next 4 lines (and start
# directly with oe_get_keys) when running the examples locally.
res = file.copy(
from = system.file("its-example.osm.pbf", package = "osmextract"),
to = file.path(tempdir(), "test_its-example.osm.pbf"),
overwrite = TRUE
)
res = oe_get("ITS Leeds", quiet = TRUE, download_directory = tempdir())
oe_find("ITS Leeds", provider = "test", download_directory = tempdir())
oe_find(
"ITS Leeds", provider = "test",
download_directory = tempdir(), return_gpkg = FALSE
)
## Not run:
oe_find("Isle of Wight", download_directory = tempdir())
oe_find("Malta", download_if_missing = TRUE, download_directory = tempdir())
oe_find(
"Leeds",
provider = "bbbike",
download_if_missing = TRUE,
download_directory = tempdir(),
return_pbf = FALSE
)
## End(Not run)
# Remove .pbf and .gpkg files in tempdir
oe_clean(tempdir())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.