Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

oe_find

Get the location of files


Description

This function takes a place name and it returns the path of .pbf and .gpkg files associated with it.

Usage

oe_find(
  place,
  provider = "geofabrik",
  download_directory = oe_download_directory(),
  download_if_missing = FALSE,
  ...
)

Arguments

place

Description of the geographical area that should be matched with a .osm.pbf file through the chosen provider. Can be either a length-1 character vector, an sf or sfc object, or a numeric vector of coordinates with length 2. In the last case, it is assumed that the EPSG code is 4326 specified as c(LON, LAT), while you can use any CRS with an sf or sfc object. See Details and examples in oe_match().

provider

Which provider should be used to download the data? Available providers can be found with the following command: oe_providers(). For oe_get() and oe_match(), if place is equal to ITS Leeds, then provider is set equal to test. This is just for simple examples and internal tests.

download_directory

Directory where the files downloaded by osmextract are stored. By default it is equal to oe_download_directory().

download_if_missing

Attempt to download the file if it cannot be found? FALSE by default.

...

Extra arguments that are passed to oe_match() and oe_get(). Please note that you cannot modify the argument download_only.

Details

The matching between the existing files (saved in a directory specified by download_directory parameter) and the input place is performed using list.files, setting a pattern equal to the basename of the URL associated to the input place. For example, if you specify place = "Isle of Wight", then the input place is matched with a URL of a .osm.pbf file (via oe_match()) and the matching is performed setting a pattern equal to the basename of that URL.

If there is no file in download_directory that can be matched with the basename and download_if_missing parameter is equal to TRUE, then the function tries to download and translate a new file from the chosen provider (geofabrik is the default provider). If download_if_missing parameter is equal to FALSE (default value), then the function stops with an error.

Value

A character vector of length one (or two) representing the path(s) of the corresponding .pbf (and .gpkg) files.

Examples

res = oe_get("ITS Leeds", provider = "test")
oe_find("ITS Leeds", provider = "test")
## Not run: 
oe_find("Isle of Wight")
oe_find("Isle of Wight", download_if_missing = TRUE)
oe_find("Leeds", provider = "bbbike", download_if_missing = TRUE)
## End(Not run)

osmextract

Download and Read OpenStreetMap Data Extracts

v0.2.1
GPL-3
Authors
Andrea Gilardi [aut, cre] (<https://orcid.org/0000-0002-9424-7439>), Robin Lovelace [aut] (<https://orcid.org/0000-0001-5679-6536>), Barry Rowlingson [ctb] (<https://orcid.org/0000-0002-8586-6625>), Salva Fernández [rev] (Salva reviewed the package (v. 0.1) for rOpenSci, see <https://github.com/ropensci/software-review/issues/395>), Nicholas Potter [rev] (Nicholas reviewed the package (v. 0.1) for rOpenSci, see <https://github.com/ropensci/software-review/issues/395>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.