Learn R Programming

osmdata (version 0.4.1)

osm_elevation: osm_elevation

Description

Add elevation data to a previously-extracted OSM data set, using a pre-downloaded elevation file (see Details). Currently only works for SC-class objects returned from osmdata_sc().

Usage

osm_elevation(dat, elev_file)

Value

A modified version of the input dat with an additional z_ column appended to the vertices.

Arguments

dat

An SC object produced by osmdata_sc().

elev_file

A vector of one or more character strings specifying paths to .tif files (or anything that terra can read) containing global elevation data. .zip files will be uncompressed.

Details

Elevation data can be downloaded from https://portal.opentopography.org/raster?opentopoID=OTSRTM.082015.4326.1, https://www.earthdata.nasa.gov/data/catalog/lpcloud-srtmgl1-003 or similar.

See Also

Other transform: osm_poly2line(), trim_osmdata(), unique_osmdata(), unname_osmdata_sf()

Examples

Run this code
if (FALSE) {
query <- opq ("omaha nebraska") |>
    add_osm_feature (key = "highway")
# Elevation can only be applied to \pkg{silicate} 'SC'-class data:
dat <- osmdata_sc (query)
dat$vertex
# The vertex table will have columns ("x_", "y_", "vertex_"). Then
# download elevation data, and add elevation column, "z_" with:
dat <- osm_elevation (dat, elev_file = "/path/to/elevation/data.tiff")
}

Run the code above in your browser using DataLab