# NOT RUN {
# Read an existing .pbf file. First we need to copy a .pbf file into a
# temporary directory
file.copy(
from = system.file("its-example.osm.pbf", package = "osmextract"),
to = file.path(tempdir(), "its-example.osm.pbf")
)
my_pbf = file.path(tempdir(), "its-example.osm.pbf")
oe_read(my_pbf)
oe_read(my_pbf, layer = "points") # Read a new layer
# The following example shows how to add new tags
names(oe_read(my_pbf, extra_tags = c("oneway", "ref"), quiet = FALSE))
# Read an existing .gpkg file. This file was created by oe_read
my_gpkg = file.path(tempdir(), "its-example.gpkg")
oe_read(my_gpkg)
# You cannot add any layer to an existing .gpkg file but you can extract some
# of the tags in other_tags. Check oe_get_keys() for more details.
names(oe_read(my_gpkg, extra_tags = c("maxspeed"))) # doesn't work
# Instead, use the query argument
names(oe_read(
my_gpkg,
quiet = TRUE,
query =
"SELECT *,
hstore_get_value(other_tags, 'maxspeed') AS maxspeed
FROM lines
"
))
# Read from a URL
my_url = "https://github.com/ropensci/osmextract/raw/master/inst/its-example.osm.pbf"
# Please note that if you read from a URL which is not linked to one of the
# supported providers, you need to specify the provider parameter:
# }
# NOT RUN {
oe_read(my_url, provider = "test", quiet = FALSE)
# }
Run the code above in your browser using DataLab