JeremyGelb / spNetwork

An R package to perform spatial analysis on networks.
GNU General Public License v2.0
34 stars 2 forks source link

Network k_cross_function: Error Points are snapped to the exact same location #23

Open ThomasX94 opened 3 weeks ago

ThomasX94 commented 3 weeks ago

Thank you for your work. I got a set of hard braking events and police reported traffic accidents. Now i want to test with the network-k-cross function if hard braking events are clustered around accidents and vice versa. However no matter how low i set the agg parameter i always get the following Error: _Error in cross_kfunctions(main_network_mtl, bike_accidents, mtllibraries, : After snapping the points on the network, some of them share the same location. To correct it, please consider setting or increasing the value of the parameter agg. They will be merged and their weights added

I also get this error message when using the bike accidents data sample provided by spNetwork in this example: result <- cross_kfunctions(main_network_mtl, bike_accidents, mtl_libraries, start = 0, end = 200, step = 10, width = 15, nsim = 50, conf_int = 0.05, digits = 2, tol = 0.1,verbose = FALSE, agg=NULL)

JeremyGelb commented 2 weeks ago

Hello !

Indeed, I did not have a lot of time to spend on this function. The error is raised because this functions is not well adapted for the moment to data that share the exact same location on the network.

Indeed, events at the same location will have a distance of 0 between them. The error is raised when points share the same location after been projected on the network. The error message suggest to INCREASE the value of agg. By doing it, you will merge close points before snapping them on the network and reduce the change to get this error.

I will try to implement soon a solution where points at the same location on the network are merged.