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

osm_lines

Extract all osm_lines from an osmdata object


Description

If id is of a point object, osm_lines will return all lines containing that point. If id is of a line or polygon object, osm_lines will return all lines which intersect the given line or polygon.

Usage

osm_lines(dat, id)

Arguments

dat

An object of class osmdata

id

OSM identification of one or more objects for which lines are to be extracted

Value

An sf Simple Features Collection of linestrings

See Also

Examples

## Not run: 
dat <- opq ("hengelo nl") %>%
    add_osm_feature (key = "highway") %>%
    osmdata_sf ()
bus <- dat$osm_points [which (dat$osm_points$highway == "bus_stop"), ] %>%
    rownames () # all OSM IDs of bus stops
osm_lines (dat, bus) # all highways containing bus stops

# All lines which intersect with Piccadilly Circus in London, UK
dat <- opq ("Fitzrovia London") %>%
    add_osm_feature (key = "highway") %>%
    osmdata_sf ()
i <- which (dat$osm_polygons$name == "Piccadilly Circus")
id <- rownames (dat$osm_polygons [i, ])
osm_lines (dat, id)

## End(Not run)

osmdata

Import 'OpenStreetMap' Data as Simple Features or Spatial Objects

v0.1.10
GPL-3
Authors
Mark Padgham [aut, cre], Bob Rudis [aut], Robin Lovelace [aut], Maëlle Salmon [aut], Andrew Smith [ctb], James Smith [ctb], Andrea Gilardi [ctb], Enrico Spinielli [ctb], Anthony North [ctb], Martin Machyna [ctb], Marcin Kalicinski [ctb, cph] (Author of included RapidXML code)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.