ropensci / stplanr

Sustainable transport planning with R
https://docs.ropensci.org/stplanr
Other
419 stars 66 forks source link

Add arguments to rnet_merge() preventing sideroads getting values of main roads #520

Closed Robinlovelace closed 1 year ago

Robinlovelace commented 1 year ago

Reproducible example showing this behaviour with high values on sideroads:

remotes::install_dev("stplanr")
#> Using github PAT from envvar GITHUB_PAT
#> Skipping install of 'stplanr' from a github remote, the SHA1 (6583e631) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(stplanr)

rnet_x = rnet_subset(osm_net_example[1], route_network_small)
#> Warning: attribute variables are assumed to be spatially constant throughout
#> all geometries
#> Warning in st_cast.sf(sf::st_cast(x, "MULTILINESTRING"), "LINESTRING"):
#> repeating attributes for all sub-geometries for which they may not be constant
# The source object:
rnet_y = route_network_small["flow"]
rnet_y$quietness = rnorm(nrow(rnet_y))
funs = list(flow = sum, quietness = mean)
rnet_merged = rnet_merge(rnet_x[1], rnet_y[c("flow", "quietness")],
                         dist = 9, segment_length = 20, funs = funs)
#> Warning: attribute variables are assumed to be spatially constant throughout
#> all geometries

#> Warning: repeating attributes for all sub-geometries for which they may not be
#> constant
#> Linking to GEOS 3.11.1, GDAL 3.6.4, PROJ 9.1.1; sf_use_s2() is TRUE
#> Warning: st_centroid assumes attributes are constant over geometries
#> Joining with `by = join_by(osm_id)`
plot(rnet_y["flow"])

plot(rnet_merged["flow"])

Created on 2023-08-24 with reprex v2.0.2

See https://github.com/nptscot/networkmerge/issues/54 for details

Robinlovelace commented 1 year ago

Interesting separate issue identified here: bridge over lady beck isn't being picked-up:

image

Robinlovelace commented 1 year ago

Latest version avoids sideroads, I think, but worsens the problem of missing links for sections in x that are short.

Robinlovelace commented 1 year ago

image