50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

osmapiR (version 0.2.3)

st_as_sf: Convert osmapiR objects to sf objects

Description

Convert osmapiR objects to sf objects

Usage

st_as_sf.osmapi_map_notes(x, ...)

st_as_sf.osmapi_changesets(x, ...)

st_as_sf.osmapi_gps_track(x, format = c("line", "points"), ...)

st_as_sf.osmapi_gpx(x, format = c("lines", "points"), ...)

Value

Returns a sf object from sf package or a list of for osmapi_gpx and format = "points".

When x is a osmapi_gps_track or osmapi_gpx object and format = "line", the result will have XYZM dimensions for coordinates, elevation and time if available. In this format, time will loss the POSIXct type as only numeric For format = "points", the result will have XY dimensions and elevation and time will be independent columns if available.

Arguments

x

an osmapiR object.

...

passed on to st_as_sf() from sf package.

format

Format of the output. If "line" (the default), return a sf object with one LINESTRING for each track. If "points", return a sf with the POINTs of the track as features. See below for details.

See Also

st_as_sf() from sf package.

Other methods: tags_list2wide()

Examples

Run this code
note <- osm_get_notes(note_id = "2067786")
sf::st_as_sf(note)

chaset <- osm_get_changesets(changeset_id = 137595351, include_discussion = TRUE)
sf::st_as_sf(chaset)

gpx <- osm_get_points_gps(bbox = c(-0.3667545, 40.2153246, -0.3354263, 40.2364915))
sf::st_as_sf(gpx, format = "line")
sf::st_as_sf(gpx, format = "points")

if (FALSE) {
# Requires authentication
trk <- osm_get_data_gpx(gpx_id = 3498170, format = "R")
sf::st_as_sf(trk, format = "line")
sf::st_as_sf(trk, format = "points")
}

Run the code above in your browser using DataLab