Closed agila5 closed 4 years ago
Fix #59. Some (probably redundant) tests using geofabrik and bbbike data:
# packages library(sf) library(sfnetworks) # I need a function to download a convert osm.pbf file into .gpkg format: my_conversion <- function(url) { my_destfile <- paste0(tempfile(), ".osm.pbf") download.file( url = url, destfile = my_destfile, mode = "wb" ) my_destination <- paste0(tempfile(), ".gpkg") gdal_utils( util = "vectortranslate", source = my_destfile, destination = my_destination, options = c("-f", "GPKG", "-overwrite", "lines") ) my_destination } # some tests (chosen at random from bbbike) # 1 - Bristol bristol <- my_conversion("https://download.bbbike.org/osm/bbbike/Bristol/Bristol.osm.pbf") bristol_sf <- st_read(bristol) bristol_sfnetworks <- as_sfnetwork(bristol_sf) bristol_sfnetworks #> # An sfnetwork with 171580 nodes and 110742 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 66820 components with spatially explicit edges #> # #> # Node Data: 171,580 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: -2.929998 ymin: 51.34 xmax: -2.270001 ymax: 51.59 #> geom #> <POINT [°]> #> 1 (-2.609721 51.36571) #> 2 (-2.607409 51.36442) #> 3 (-2.619123 51.36762) #> 4 (-2.619497 51.36725) #> 5 (-2.604642 51.3713) #> 6 (-2.573867 51.3866) #> # ... with 171,574 more rows #> # #> # Edge Data: 110,742 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: -2.929998 ymin: 51.34 xmax: -2.270001 ymax: 51.59 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 190 The ~ second~ <NA> <NA> <NA> <NA> 6 #> 2 3 4 193 Dark~ unclas~ <NA> <NA> <NA> <NA> 3 #> 3 5 6 196 Nort~ unclas~ <NA> <NA> <NA> <NA> 3 #> # ... with 110,739 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]> # 2 - Goeteborg goeteborg <- my_conversion("https://download.bbbike.org/osm/bbbike/Goeteborg/Goeteborg.osm.pbf") goeteborg_sf <- st_read(goeteborg) goeteborg_sfnetworks <- as_sfnetwork(goeteborg_sf) goeteborg_sfnetworks #> # An sfnetwork with 103759 nodes and 69039 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 38022 components with spatially explicit edges #> # #> # Node Data: 103,759 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: 11.7 ymin: 57.55 xmax: 12.22 ymax: 57.82 #> geom #> <POINT [°]> #> 1 (12.15126 57.70716) #> 2 (12.14949 57.70701) #> 3 (12.09217 57.67335) #> 4 (12.09134 57.67338) #> 5 (11.97431 57.70892) #> 6 (11.97995 57.70989) #> # ... with 103,753 more rows #> # #> # Edge Data: 69,039 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: 11.7 ymin: 57.55 xmax: 12.22 ymax: 57.82 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 36789~ Öjer~ reside~ <NA> <NA> <NA> <NA> 3 #> 2 3 4 38466~ <NA> motorw~ <NA> <NA> <NA> <NA> 9 #> 3 5 6 39940~ <NA> <NA> <NA> <NA> <NA> <NA> 5 #> # ... with 69,036 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]> rm(list = setdiff(ls(), "my_conversion")) # 3 - Memphis memphis <- my_conversion("https://download.bbbike.org/osm/bbbike/Memphis/Memphis.osm.pbf") memphis_sf <- st_read(memphis) memphis_sfnetworks <- as_sfnetwork(memphis_sf) memphis_sfnetworks #> # An sfnetwork with 148084 nodes and 88738 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 61847 components with spatially explicit edges #> # #> # Node Data: 148,084 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: -90.35987 ymin: 34.91 xmax: -89.65 ymax: 35.31999 #> geom #> <POINT [°]> #> 1 (-90.19383 35.21924) #> 2 (-90.16959 35.21376) #> 3 (-90.35716 35.00212) #> 4 (-90.35956 35.00295) #> 5 (-90.32045 35.00169) #> 6 (-90.18696 35.19314) #> # ... with 148,078 more rows #> # #> # Edge Data: 88,738 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: -90.35987 ymin: 34.91 xmax: -89.65 ymax: 35.31999 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 12772~ Rive~ reside~ <NA> <NA> <NA> <NA> 3 #> 2 3 4 12772~ R O ~ reside~ <NA> <NA> <NA> <NA> 3 #> 3 3 5 12772~ R O ~ service <NA> <NA> <NA> <NA> 0 #> # ... with 88,735 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]> # 4 - SantaCruz santacruz <- my_conversion("https://download.bbbike.org/osm/bbbike/SantaCruz/SantaCruz.osm.pbf") santacruz_sf <- st_read(santacruz) santacruz_sfnetworks <- as_sfnetwork(santacruz_sf) santacruz_sfnetworks #> # An sfnetwork with 123639 nodes and 83133 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 45433 components with spatially explicit edges #> # #> # Node Data: 123,639 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: -122.3 ymin: 36.78 xmax: -121.5 ymax: 37.27 #> geom #> <POINT [°]> #> 1 (-121.9553 37.25616) #> 2 (-121.9549 37.25582) #> 3 (-121.7679 37.24178) #> 4 (-121.7702 37.24207) #> 5 (-121.9626 37.2579) #> 6 (-121.9625 37.25781) #> # ... with 123,633 more rows #> # #> # Edge Data: 83,133 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: -122.3 ymin: 36.78 xmax: -121.5 ymax: 37.27 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 43799~ <NA> motorw~ <NA> <NA> <NA> <NA> 9 #> 2 3 4 48593~ <NA> motorw~ <NA> <NA> <NA> <NA> 49 #> 3 5 6 48603~ <NA> motorw~ <NA> <NA> <NA> <NA> 9 #> # ... with 83,130 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]> # 5 - Turin turin <- my_conversion("https://download.bbbike.org/osm/bbbike/Turin/Turin.osm.pbf") turin_sf <- st_read(turin) turin_sfnetworks <- as_sfnetwork(turin_sf) turin_sfnetworks #> # An sfnetwork with 95266 nodes and 68769 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 31739 components with spatially explicit edges #> # #> # Node Data: 95,266 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: 7.430007 ymin: 44.94 xmax: 7.929998 ymax: 45.21 #> geom #> <POINT [°]> #> 1 (7.668122 45.03458) #> 2 (7.665927 45.02885) #> 3 (7.615258 45.08539) #> 4 (7.615737 45.08524) #> 5 (7.623182 45.06441) #> 6 (7.627943 45.05858) #> # ... with 95,260 more rows #> # #> # Edge Data: 68,769 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: 7.430001 ymin: 44.94 xmax: 7.929998 ymax: 45.21 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 45465~ Via ~ tertia~ <NA> <NA> <NA> <NA> 9 #> 2 3 4 45492~ Via ~ reside~ <NA> <NA> <NA> <NA> 3 #> 3 5 6 45496~ Via ~ second~ <NA> <NA> <NA> <NA> 6 #> # ... with 68,766 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]> # A few more tests taken from Geofabrik rwanda <- my_conversion("http://download.geofabrik.de/africa/rwanda-latest.osm.pbf") rwanda_sf <- st_read(rwanda) rwanda_sfnetworks <- as_sfnetwork(rwanda_sf) rwanda_sfnetworks #> # An sfnetwork with 115626 nodes and 72877 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 44082 components with spatially explicit edges #> # #> # Node Data: 115,626 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: 28.79429 ymin: -3.36603 xmax: 31.29422 ymax: -0.8261649 #> geom #> <POINT [°]> #> 1 (30.12383 -1.965917) #> 2 (30.15481 -1.971303) #> 3 (29.2581 -1.681707) #> 4 (29.25962 -1.672762) #> 5 (28.90985 -2.455959) #> 6 (28.90609 -2.468565) #> # ... with 115,620 more rows #> # #> # Edge Data: 72,877 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: 28.79429 ymin: -3.36603 xmax: 31.29422 ymax: -0.8261649 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 61305~ <NA> <NA> <NA> <NA> <NA> <NA> 0 #> 2 3 4 90497~ <NA> <NA> <NA> <NA> <NA> <NA> 0 #> 3 5 6 10188~ <NA> <NA> <NA> <NA> <NA> <NA> 0 #> # ... with 72,874 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]> # The following is the examples that used to fail south_yorkshire <- my_conversion("https://download.geofabrik.de/europe/great-britain/england/south-yorkshire-latest.osm.pbf") south_yorkshire_sf <- st_read(south_yorkshire) south_yorkshire_sfnetworks <- as_sfnetwork(south_yorkshire_sf) south_yorkshire_sfnetworks #> # An sfnetwork with 153657 nodes and 98913 edges #> # #> # CRS: WGS 84 #> # #> # A directed multigraph with 58779 components with spatially explicit edges #> # #> # Node Data: 153,657 x 1 (active) #> # Geometry type: POINT #> # Dimension: XY #> # Bounding box: xmin: -2.009351 ymin: 53.20363 xmax: -0.7399932 ymax: 53.76576 #> geom #> <POINT [°]> #> 1 (-1.261915 53.42453) #> 2 (-1.264852 53.42527) #> 3 (-1.248379 53.42809) #> 4 (-1.170382 53.4699) #> 5 (-1.140332 53.48276) #> 6 (-1.145685 53.4804) #> # ... with 153,651 more rows #> # #> # Edge Data: 98,913 x 12 #> # Geometry type: LINESTRING #> # Dimension: XY #> # Bounding box: xmin: -2.029702 ymin: 53.20363 xmax: -0.7398859 ymax: 53.76576 #> from to osm_id name highway waterway aerialway barrier man_made z_order #> <int> <int> <fct> <fct> <fct> <fct> <fct> <fct> <fct> <int> #> 1 1 2 26263~ Main~ second~ <NA> <NA> <NA> <NA> 6 #> 2 3 4 27001~ <NA> motorw~ <NA> <NA> <NA> <NA> 9 #> 3 5 6 27017~ <NA> motorw~ <NA> <NA> <NA> <NA> 9 #> # ... with 98,910 more rows, and 2 more variables: other_tags <fct>, #> # geom <LINESTRING [°]>
Created on 2020-06-21 by the reprex package (v0.3.0)
Fix #59. Some (probably redundant) tests using geofabrik and bbbike data:
Created on 2020-06-21 by the reprex package (v0.3.0)