st_as_sf: Convert osmapiR objects to sf objects

st_as_sfR Documentation

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"), ...)

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.

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.

See Also

st_as_sf() from sf package.

Other methods: tags_list2wide()

Examples

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")

## Not run: 
# 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")

## End(Not run)


osmapiR documentation built on April 15, 2025, 9:06 a.m.