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

oe_get_keys

Return all keys stored in "other_tags" column


Description

This function is used to return the names of all keys that are stored in "other_tags" column since they were not explicitly included in the file. See Details.

Usage

oe_get_keys(zone, layer = "lines")

## Default S3 method:
oe_get_keys(zone, layer = "lines")

## S3 method for class 'character'
oe_get_keys(zone, layer = "lines")

## S3 method for class 'sf'
oe_get_keys(zone, layer = "lines")

Arguments

zone

An sf object (typically read-in with oe_read() or oe_get()) with an other_tags field, or a character vector (of length 1) that points to a .gpkg file (typically created using oe_vectortranslate() or oe_get()).

layer

Which layer should be read in? Typically points, lines (the default), multilinestrings, multipolygons or other_relations. If you specify an ad-hoc query using the argument query (see introductory vignette and examples), then oe_get() and oe_read() will read the layer specified in the query and ignore layer. See also #122.

Details

OSM data are typically documented using several tags. A tag is a pair of two items, namely a key and a value. As we documented in oe_vectortranslate(), the conversion between .osm.pbf and .gpkg formats is governed by a CONFIG file that indicates which tags are explicitly added to the .gpkg file. All the other keys stored in the .osm.pbf file are automatically appended using an "other_tags" field, with a syntax compatible with the PostgreSQL HSTORE type. This function is used to display the names of all keys stored in the "other_tags" column.

You can also use the hstore_get_value() function from GDAL to extract one particular tag from an existing .gpkg file. Check the introductory vignette and see examples.

The definition of a generic S3 implementation started in osmextract/issues/138.

Value

A character vector indicating the name of all keys stored in "other_tags" field.

See Also

oe_vectortranslate() and osmextract/issues/107.

Examples

itsleeds_gpkg_path = oe_get("ITS Leeds", download_only = TRUE)
oe_get_keys(itsleeds_gpkg_path)

itsleeds = oe_get("ITS Leeds")
oe_get_keys(itsleeds)

# Add an extra key to an existing .gpkg file without vectortranslate
names(oe_read(
  itsleeds_gpkg_path,
  query = "SELECT *,  hstore_get_value(other_tags, 'oneway')  AS oneway FROM lines"
))

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.