Get the roads of an area. Either by name of area (inPerioxi) or by bounding box (incoordinates).

osm.getRoads(
  incoordinates = c(26.545029, 39.088569, 26.570177, 39.11681),
  inPerioxi = "Mytilene Municipal Unit",
  withBB = FALSE,
  outcrs = 2100
)

Arguments

incoordinates

Four coordinates of the bounding box.

inPerioxi

Name of an area

withBB

Boolean indicating if we shall use a bounding box (incoordinates) or the name of an area (inPerioxi).

outcrs

CRS of the the output

Value

An sfnetwork

Author

Dimitris Kavroudakis dimitris123@gmail.com

Examples

library(goal)
library(sf)
library(sfnetworks)
library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
mynetwork = osm.getRoads(incoordinates= c(26.545029,39.088569,26.570177,39.116810),
  withBB=TRUE, outcrs=2100
)
#> 
#> Using bbox
#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
mynetwork
#> # A sfnetwork with 1006 nodes and 740 edges
#> #
#> # CRS:  EPSG:2100 
#> #
#> # An undirected multigraph with 283 components with spatially explicit edges
#> #
#> # A tibble: 1,006 × 1
#>             geometry
#>          <POINT [m]>
#> 1 (720570.8 4331266)
#> 2 (719927.1 4331309)
#> 3 (721299.6 4331289)
#> 4 (721287.5 4331404)
#> 5 (721242.4 4331241)
#> 6 (721069.4 4331400)
#> # ℹ 1,000 more rows
#> #
#> # A tibble: 740 × 6
#>    from    to osm_id   name             highway                         geometry
#>   <int> <int> <chr>    <chr>            <chr>                   <LINESTRING [m]>
#> 1     1     2 39428970 Ζωοδόχου Πηγής   primary (720570.8 4331266, 720530.6 433…
#> 2     3     4 40847716 8ης Νοεμβρίου    primary (721299.6 4331289, 721295.2 433…
#> 3     3     5 40847725 Αργύρη Εφταλιώτη primary (721242.4 4331241, 721299.6 433…
#> # ℹ 737 more rows

mynetwork2 = osm.getRoads(inPerioxi="Mytilene Municipal Unit",
  withBB=FALSE, outcrs=2100
)
#> 
#> Using name of area
#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
mynetwork2
#> # A sfnetwork with 2544 nodes and 1823 edges
#> #
#> # CRS:  EPSG:2100 
#> #
#> # An undirected multigraph with 770 components with spatially explicit edges
#> #
#> # A tibble: 2,544 × 1
#>             geometry
#>          <POINT [m]>
#> 1 (720570.8 4331266)
#> 2 (719927.1 4331309)
#> 3 (721299.6 4331289)
#> 4 (721287.5 4331404)
#> 5 (721242.4 4331241)
#> 6 (721069.4 4331400)
#> # ℹ 2,538 more rows
#> #
#> # A tibble: 1,823 × 6
#>    from    to osm_id   name             highway                         geometry
#>   <int> <int> <chr>    <chr>            <chr>                   <LINESTRING [m]>
#> 1     1     2 39428970 Ζωοδόχου Πηγής   primary (720570.8 4331266, 720530.6 433…
#> 2     3     4 40847716 8ης Νοεμβρίου    primary (721299.6 4331289, 721295.2 433…
#> 3     3     5 40847725 Αργύρη Εφταλιώτη primary (721242.4 4331241, 721299.6 433…
#> # ℹ 1,820 more rows