A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ropensci/stplanr/issues/240 below:

SpatialLinesNetwork not working with sf objects · Issue #240 · ropensci/stplanr · GitHub

Just testing this on OSM data and found a bug that also affects our test data:

library(stplanr)
library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.2.2, proj.4 4.9.2

# rnet example
class(route_network)
#> [1] "SpatialLinesDataFrame"
#> attr(,"package")
#> [1] "sp"
SLN = SpatialLinesNetwork(route_network)
class(SLN)
#> [1] "SpatialLinesNetwork"
#> attr(,"package")
#> [1] "stplanr"
weightfield(SLN)  # field used to determine shortest path
#> [1] "length"
plot(SLN)
from_id = 1
to_id = 50
points(sln2points(SLN)[from_id, ], cex = 5)
points(sln2points(SLN)[to_id, ], cex = 5)
shortpath <- sum_network_routes(SLN, from_id, to_id, sumvars = "length")
plot(shortpath, col = "red", lwd = 4, add = TRUE)

SLN_sf = SpatialLinesNetwork(st_as_sf(route_network))
#> Error in mutate_impl(.data, dots): Evaluation error: This function should not be called directly.

# Another example from OSM
r = opq(bbox = c(0, 53, 0.5, 53.5)) %>% add_osm_feature("highway", "primary") %>% 
  osmdata_sf()
ways = r$osm_lines
summary(st_geometry_type(ways))
#>           GEOMETRY              POINT         LINESTRING 
#>                  0                  0                 94 
#>            POLYGON         MULTIPOINT    MULTILINESTRING 
#>                  0                  0                  0 
#>       MULTIPOLYGON GEOMETRYCOLLECTION     CIRCULARSTRING 
#>                  0                  0                  0 
#>      COMPOUNDCURVE       CURVEPOLYGON         MULTICURVE 
#>                  0                  0                  0 
#>       MULTISURFACE              CURVE            SURFACE 
#>                  0                  0                  0 
#>  POLYHEDRALSURFACE                TIN           TRIANGLE 
#>                  0                  0                  0
plot(ways)
#> Warning: plotting the first 9 out of 21 attributes; use max.plot = 21 to
#> plot all

ways_sln = SpatialLinesNetwork(ways)
#> Error in mutate_impl(.data, dots): Evaluation error: This function should not be called directly.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4