Find, download, translate and read OSM extracts from several providers
This function is used to find, download, translate and read OSM extracts
obtained from several providers. It is a wrapper around oe_match()
and
oe_read()
. Check the introductory vignette, the examples and the help pages
of the wrapped functions to understand the details behind all parameters.
oe_get( place, layer = "lines", ..., provider = "geofabrik", match_by = "name", max_string_dist = 1, level = NULL, download_directory = oe_download_directory(), force_download = FALSE, max_file_size = 5e+08, vectortranslate_options = NULL, osmconf_ini = NULL, extra_tags = NULL, force_vectortranslate = FALSE, download_only = FALSE, skip_vectortranslate = FALSE, never_skip_vectortranslate = FALSE, quiet = FALSE )
place |
Description of the geographical area that should be matched with
a |
layer |
Which |
... |
Arguments that will be passed to |
provider |
Which provider should be used to download the data? Available
providers can be found with the following command: |
match_by |
Which column of the provider's database should be used for
matching the input |
max_string_dist |
Numerical value greater or equal than 0. What is the
maximum distance in fuzzy matching (i.e. Approximate String Distance, see
|
level |
An integer representing the desired hierarchical level in case
of spatial matching. For the |
download_directory |
Where to download the file containing the OSM data?
By default this is equal to |
force_download |
Should the |
max_file_size |
The maximum file size to download without asking in
interactive mode. Default: |
vectortranslate_options |
Options passed to the |
osmconf_ini |
The configuration file. See documentation at
gdal.org. Check details in the
introductory vignette and the help page of |
extra_tags |
Which additional columns, corresponding to OSM tags, should
be in the resulting dataset? |
force_vectortranslate |
Boolean. Force the original |
download_only |
Boolean. If |
skip_vectortranslate |
Boolean. If |
never_skip_vectortranslate |
Boolean. This is used in case the user
passed its own |
quiet |
Boolean. If |
The algorithm that we use for importing an OSM extract data into R
is divided into 4 steps: 1) match the input place
with the url of a
.pbf
file; 2) download the .pbf
file; 3) convert it into .gpkg
format
and 4) read-in the .gpkg
file. The function oe_match()
is used to
perform the first operation and the function oe_read()
(which is a
wrapper around oe_download()
, oe_vectortranslate()
and sf::st_read()
)
performs the other three operations.
An sf
object.
# Download OSM extracts associated to a simple test. its = oe_get("ITS Leeds", quiet = FALSE) class(its) unique(sf::st_geometry_type(its)) # Get another layer from the test extract its_points = oe_get("ITS Leeds", layer = "points") unique(sf::st_geometry_type(its_points)) # Get the .osm.pbf and .gpkg file path oe_get("ITS Leeds", download_only = TRUE) oe_get("ITS Leeds", download_only = TRUE, skip_vectortranslate = TRUE) # See also ?oe_find() # Add additional tags its_with_oneway = oe_get("ITS Leeds", extra_tags = "oneway", quiet = FALSE) names(its_with_oneway) table(its_with_oneway$oneway, useNA = "ifany") # Use the query argument to get only oneway streets: q = "SELECT * FROM 'lines' WHERE oneway IN ('yes')" its_oneway = oe_get("ITS Leeds", query = q) its_oneway ## Not run: # A more complex example west_yorkshire = oe_get("West Yorkshire", quiet = FALSE) # If you run it again, the function will not download the file # or convert it again west_yorkshire = oe_get("West Yorkshire", quiet = FALSE) # Match with place name oe_get("Milan") # Warning: the .pbf file is 400MB oe_get("Vatican City") oe_get("Zurich") # Match with coordinates (any EPSG) milan_duomo = sf::st_sfc(sf::st_point(c(1514924, 5034552)), crs = 3003) oe_get(milan_duomo, quiet = FALSE) # Warning: the .pbf file is 400MB # Match with numeric coordinates (EPSG = 4326) oe_match(c(9.1916, 45.4650), quiet = FALSE) # Alternative providers baku = oe_get(place = "Baku", provider = "bbbike", quiet = FALSE) # Other examples: oe_get("RU", match_by = "iso3166_1_alpha2", quiet = FALSE) # The following example mimics read_sf oe_get("Andora", stringsAsFactors = FALSE, quiet = TRUE, as_tibble = TRUE) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.