The output of transit_network_to_sf()
can generate routes
with invalid geometries.
library(r5r) library(ggplot2) library(sf) # build network data_path <- system.file("extdata/poa", package = "r5r") r5r_core <- setup_r5(data_path = data_path, verbose = FALSE) # extract public transport network transit_net <- transit_network_to_sf(r5r_core) # stops Ok head(transit_net$stops) ggplot() + geom_sf(data = transit_net$stops, color='gray85') + theme_void() # routes ERROR head(transit_net$routes) ggplot() + geom_sf(data = transit_net$routes, color='gray85') + theme_void() > Error in CPL_geos_is_empty(st_geometry(x)) : > Evaluation error: IllegalArgumentException: point array must contain 0 or >1 elements.suggested solution
We should check whether there are any invalid route goemetries and fixed them before returning the ouput.
if( any(FALSE, sf::st_is_valid(transit_net$routes)) ){
transit_net$routes <- st_make_valid(transit_net$routes)
}
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