I would like to do a bending between the network Riv
and the points df
with the function
library(sf)
net <- as_sfnetwork(Riv) |>
st_network_blend(df)
Nevertheless in this exemple, two points are removed in the output (38, 120). I am looking for a way to bend all the points in the given network.
Riv <- structure(list(id = 1, geometry = structure(list(structure(c(279507.756152689,
279496.389160699, 279487.579741907, 279477.065274316, 279471.665953121,
279467.971680724, 279462.288184729, 279457.173038333, 279450.352843139,
279448.079444741, 279430.176432356, 279416.820216768, 279397.212155585,
279392.665358789, 279355.154285221, 279354.301760822, 279338.956321635,
279324.747581647, 279315.938162855, 279302.581947266, 279294.625052873,
279284.394760082, 279266.207572898, 279253.419706909, 279246.599511714,
279236.369218923, 279223.297178134, 126843.360320325, 126845.349543923,
126847.054592722, 126849.896340719, 126851.601389518, 126851.601389518,
126851.601389518, 126849.896340719, 126849.32799112, 126849.04381632,
126855.011487115, 126860.41080831, 126873.482849099, 126880.587219093,
126900.763629875, 126901.616154274, 126906.44712587, 126907.29965027,
126905.026251872, 126901.616154274, 126899.342755876, 126895.64848348,
126883.42896709, 126885.986540288, 126886.554889887, 126891.954211083,
126900.763629875), dim = c(27L, 2L), class = c("XY", "LINESTRING",
"sfg"))), n_empty = 0L, crs = structure(list(input = "BD72 / Belgian Lambert 72",
wkt = "PROJCRS[\"BD72 / Belgian Lambert 72\",\n BASEGEOGCRS[\"BD72\",\n DATUM[\"Reseau National Belge 1972\",\n ELLIPSOID[\"International 1924\",6378388,297,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4313]],\n CONVERSION[\"Belgian Lambert 72\",\n METHOD[\"Lambert Conic Conformal (2SP)\",\n ID[\"EPSG\",9802]],\n PARAMETER[\"Latitude of false origin\",90,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8821]],\n PARAMETER[\"Longitude of false origin\",4.36748666666667,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8822]],\n PARAMETER[\"Latitude of 1st standard parallel\",51.1666672333333,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8823]],\n PARAMETER[\"Latitude of 2nd standard parallel\",49.8333339,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8824]],\n PARAMETER[\"Easting at false origin\",150000.013,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8826]],\n PARAMETER[\"Northing at false origin\",5400088.438,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8827]]],\n CS[Cartesian,2],\n AXIS[\"easting (X)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"northing (Y)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"Engineering survey, topographic mapping.\"],\n AREA[\"Belgium - onshore.\"],\n BBOX[49.5,2.5,51.51,6.4]],\n ID[\"EPSG\",31370]]"), class = "crs"), class = c("sfc_LINESTRING",
"sfc"), precision = 0, bbox = structure(c(xmin = 279223.297178134,
ymin = 126843.360320325, xmax = 279507.756152689, ymax = 126907.29965027
), class = "bbox"))), row.names = c(NA, -1L), class = c("sf",
"data.frame"), sf_column = "geometry", agr = structure(c(id = NA_integer_), class = "factor", levels = c("constant",
"aggregate", "identity")))
df <- structure(list(geometry = structure(list(structure(c(279461.047725,
126850.828982), class = c("XY", "POINT", "sfg")), structure(c(279471.850771,
126850.434784), class = c("XY", "POINT", "sfg")), structure(c(279461.600959,
126853.524052), class = c("XY", "POINT", "sfg")), structure(c(279477.622451,
126848.998012), class = c("XY", "POINT", "sfg")), structure(c(279487.333524,
126846.386556), class = c("XY", "POINT", "sfg")), structure(c(279432.618277,
126855.779098), class = c("XY", "POINT", "sfg")), structure(c(279462.114815,
126853.349535), class = c("XY", "POINT", "sfg")), structure(c(279459.709928,
126852.784385), class = c("XY", "POINT", "sfg")), structure(c(279462.634304,
126853.646268), class = c("XY", "POINT", "sfg")), structure(c(279464.104559,
126852.34611), class = c("XY", "POINT", "sfg")), structure(c(279460.525507,
126852.057152), class = c("XY", "POINT", "sfg")), structure(c(279461.943233,
126851.922813), class = c("XY", "POINT", "sfg")), structure(c(279455.790451,
126849.496129), class = c("XY", "POINT", "sfg")), structure(c(279463.029965,
126850.70146), class = c("XY", "POINT", "sfg")), structure(c(279462.662644,
126850.174628), class = c("XY", "POINT", "sfg")), structure(c(279459.928063,
126851.945586), class = c("XY", "POINT", "sfg")), structure(c(279462.606883,
126854.746546), class = c("XY", "POINT", "sfg")), structure(c(279461.926269,
126852.314836), class = c("XY", "POINT", "sfg")), structure(c(279453.401994,
126849.007272), class = c("XY", "POINT", "sfg")), structure(c(279453.651751,
126849.738384), class = c("XY", "POINT", "sfg")), structure(c(279459.229805,
126851.573168), class = c("XY", "POINT", "sfg")), structure(c(279461.604216,
126851.122261), class = c("XY", "POINT", "sfg")), structure(c(279462.632447,
126852.856737), class = c("XY", "POINT", "sfg")), structure(c(279462.65262,
126852.349694), class = c("XY", "POINT", "sfg")), structure(c(279462.472094,
126853.200606), class = c("XY", "POINT", "sfg")), structure(c(279452.138754,
126849.115283), class = c("XY", "POINT", "sfg")), structure(c(279463.172444,
126850.328626), class = c("XY", "POINT", "sfg")), structure(c(279459.342917,
126849.738244), class = c("XY", "POINT", "sfg")), structure(c(279445.008342,
126849.725012), class = c("XY", "POINT", "sfg")), structure(c(279463.831275,
126853.398651), class = c("XY", "POINT", "sfg")), structure(c(279462.819294,
126850.956011), class = c("XY", "POINT", "sfg")), structure(c(279460.830336,
126852.600472), class = c("XY", "POINT", "sfg")), structure(c(279485.833601,
126847.749308), class = c("XY", "POINT", "sfg")), structure(c(279463.610849,
126852.607739), class = c("XY", "POINT", "sfg")), structure(c(279453.117239,
126850.110347), class = c("XY", "POINT", "sfg")), structure(c(279463.658051,
126850.149101), class = c("XY", "POINT", "sfg")), structure(c(279462.012276,
126850.075728), class = c("XY", "POINT", "sfg")), structure(c(279461.826927,
126853.016637), class = c("XY", "POINT", "sfg")), structure(c(279478.986862,
126849.792752), class = c("XY", "POINT", "sfg")), structure(c(279480.666583,
126850.375603), class = c("XY", "POINT", "sfg")), structure(c(279446.183482,
126850.504251), class = c("XY", "POINT", "sfg")), structure(c(279457.877851,
126850.270125), class = c("XY", "POINT", "sfg")), structure(c(279462.236599,
126851.00315), class = c("XY", "POINT", "sfg")), structure(c(279489.494214,
126847.537526), class = c("XY", "POINT", "sfg")), structure(c(279466.444841,
126851.942667), class = c("XY", "POINT", "sfg")), structure(c(279480.001968,
126849.053918), class = c("XY", "POINT", "sfg")), structure(c(279458.473767,
126850.450916), class = c("XY", "POINT", "sfg")), structure(c(279438.335202,
126854.041641), class = c("XY", "POINT", "sfg")), structure(c(279477.597359,
126850.204792), class = c("XY", "POINT", "sfg")), structure(c(279484.343244,
126846.666658), class = c("XY", "POINT", "sfg")), structure(c(279485.105268,
126848.814882), class = c("XY", "POINT", "sfg")), structure(c(279485.806615,
126845.929235), class = c("XY", "POINT", "sfg")), structure(c(279483.430773,
126850.499909), class = c("XY", "POINT", "sfg")), structure(c(279482.140866,
126848.498698), class = c("XY", "POINT", "sfg")), structure(c(279466.317559,
126851.666972), class = c("XY", "POINT", "sfg")), structure(c(279473.207856,
126849.138954), class = c("XY", "POINT", "sfg")), structure(c(279479.147495,
126850.340441), class = c("XY", "POINT", "sfg")), structure(c(279469.370398,
126850.397727), class = c("XY", "POINT", "sfg")), structure(c(279472.215248,
126852.368758), class = c("XY", "POINT", "sfg")), structure(c(279472.328427,
126851.398592), class = c("XY", "POINT", "sfg")), structure(c(279453.41179,
126849.337293), class = c("XY", "POINT", "sfg")), structure(c(279485.784208,
126847.335485), class = c("XY", "POINT", "sfg")), structure(c(279486.14318,
126846.832537), class = c("XY", "POINT", "sfg")), structure(c(279473.852034,
126849.102676), class = c("XY", "POINT", "sfg")), structure(c(279472.95162,
126852.124049), class = c("XY", "POINT", "sfg")), structure(c(279478.35171,
126850.383573), class = c("XY", "POINT", "sfg")), structure(c(279474.256748,
126848.668214), class = c("XY", "POINT", "sfg")), structure(c(279471.517068,
126850.504505), class = c("XY", "POINT", "sfg")), structure(c(279473.560632,
126850.307387), class = c("XY", "POINT", "sfg")), structure(c(279472.902263,
126851.093206), class = c("XY", "POINT", "sfg")), structure(c(279474.101945,
126852.159925), class = c("XY", "POINT", "sfg")), structure(c(279474.342943,
126851.530142), class = c("XY", "POINT", "sfg")), structure(c(279473.241454,
126850.224655), class = c("XY", "POINT", "sfg")), structure(c(279472.918423,
126851.834796), class = c("XY", "POINT", "sfg")), structure(c(279476.281047,
126847.843752), class = c("XY", "POINT", "sfg")), structure(c(279473.554013,
126852.11457), class = c("XY", "POINT", "sfg")), structure(c(279437.364954,
126850.537163), class = c("XY", "POINT", "sfg")), structure(c(279475.09422,
126848.049405), class = c("XY", "POINT", "sfg")), structure(c(279467.368493,
126851.7603), class = c("XY", "POINT", "sfg")), structure(c(279476.118381,
126852.599234), class = c("XY", "POINT", "sfg")), structure(c(279474.030119,
126851.484283), class = c("XY", "POINT", "sfg")), structure(c(279472.132073,
126849.615477), class = c("XY", "POINT", "sfg")), structure(c(279470.762018,
126851.014004), class = c("XY", "POINT", "sfg")), structure(c(279476.710636,
126850.620486), class = c("XY", "POINT", "sfg")), structure(c(279430.398141,
126855.077191), class = c("XY", "POINT", "sfg")), structure(c(279452.905725,
126849.333537), class = c("XY", "POINT", "sfg")), structure(c(279468.953731,
126851.750077), class = c("XY", "POINT", "sfg")), structure(c(279474.458842,
126851.624103), class = c("XY", "POINT", "sfg")), structure(c(279473.83588,
126850.584063), class = c("XY", "POINT", "sfg")), structure(c(279479.60999,
126849.773955), class = c("XY", "POINT", "sfg")), structure(c(279471.570311,
126851.141144), class = c("XY", "POINT", "sfg")), structure(c(279479.08071,
126851.19211), class = c("XY", "POINT", "sfg")), structure(c(279475.491207,
126851.875552), class = c("XY", "POINT", "sfg")), structure(c(279462.376662,
126851.974461), class = c("XY", "POINT", "sfg")), structure(c(279464.449914,
126850.990314), class = c("XY", "POINT", "sfg")), structure(c(279476.076152,
126850.747734), class = c("XY", "POINT", "sfg")), structure(c(279474.100852,
126850.734305), class = c("XY", "POINT", "sfg")), structure(c(279471.084995,
126854.263564), class = c("XY", "POINT", "sfg")), structure(c(279469.6689,
126851.41826), class = c("XY", "POINT", "sfg")), structure(c(279478.634543,
126850.698427), class = c("XY", "POINT", "sfg")), structure(c(279478.132384,
126849.441586), class = c("XY", "POINT", "sfg")), structure(c(279467.935292,
126850.860078), class = c("XY", "POINT", "sfg")), structure(c(279464.972597,
126852.055098), class = c("XY", "POINT", "sfg")), structure(c(279465.727472,
126852.596526), class = c("XY", "POINT", "sfg")), structure(c(279466.819062,
126850.211128), class = c("XY", "POINT", "sfg")), structure(c(279477.379878,
126852.672366), class = c("XY", "POINT", "sfg")), structure(c(279455.619918,
126849.508401), class = c("XY", "POINT", "sfg")), structure(c(279461.582409,
126850.160118), class = c("XY", "POINT", "sfg")), structure(c(279478.665487,
126849.384254), class = c("XY", "POINT", "sfg")), structure(c(279478.357877,
126851.055353), class = c("XY", "POINT", "sfg")), structure(c(279468.674094,
126850.41286), class = c("XY", "POINT", "sfg")), structure(c(279469.435244,
126852.776082), class = c("XY", "POINT", "sfg")), structure(c(279475.598089,
126849.419795), class = c("XY", "POINT", "sfg")), structure(c(279470.731167,
126851.555642), class = c("XY", "POINT", "sfg")), structure(c(279459.830752,
126851.520698), class = c("XY", "POINT", "sfg")), structure(c(279460.39306,
126851.010528), class = c("XY", "POINT", "sfg")), structure(c(279486.186951,
126845.877251), class = c("XY", "POINT", "sfg")), structure(c(279460.816828,
126852.562426), class = c("XY", "POINT", "sfg")), structure(c(279482.648044,
126848.326928), class = c("XY", "POINT", "sfg")), structure(c(279461.833796,
126853.736982), class = c("XY", "POINT", "sfg")), structure(c(279480.17933,
126850.945485), class = c("XY", "POINT", "sfg")), structure(c(279466.752634,
126853.207904), class = c("XY", "POINT", "sfg")), structure(c(279470.166005,
126852.904565), class = c("XY", "POINT", "sfg")), structure(c(279454.818492,
126849.688792), class = c("XY", "POINT", "sfg")), structure(c(279460.255726,
126853.538839), class = c("XY", "POINT", "sfg")), structure(c(279489.355847,
126846.681466), class = c("XY", "POINT", "sfg")), structure(c(279487.706023,
126846.023335), class = c("XY", "POINT", "sfg")), structure(c(279456.581215,
126850.643081), class = c("XY", "POINT", "sfg")), structure(c(279462.892312,
126851.437007), class = c("XY", "POINT", "sfg")), structure(c(279460.332868,
126850.187095), class = c("XY", "POINT", "sfg")), structure(c(279462.814175,
126853.932974), class = c("XY", "POINT", "sfg")), structure(c(279466.178942,
126850.579383), class = c("XY", "POINT", "sfg")), structure(c(279483.468619,
126847.662682), class = c("XY", "POINT", "sfg")), structure(c(279458.089547,
126851.130423), class = c("XY", "POINT", "sfg")), structure(c(279461.667497,
126849.783768), class = c("XY", "POINT", "sfg")), structure(c(279484.103686,
126847.929406), class = c("XY", "POINT", "sfg")), structure(c(279469.168623,
126854.072839), class = c("XY", "POINT", "sfg")), structure(c(279459.792793,
126851.975168), class = c("XY", "POINT", "sfg")), structure(c(279482.675889,
126847.03776), class = c("XY", "POINT", "sfg")), structure(c(279465.177138,
126850.52086), class = c("XY", "POINT", "sfg")), structure(c(279471.732504,
126851.978363), class = c("XY", "POINT", "sfg")), structure(c(279472.962478,
126849.66225), class = c("XY", "POINT", "sfg")), structure(c(279464.488014,
126852.960836), class = c("XY", "POINT", "sfg")), structure(c(279465.083755,
126851.037086), class = c("XY", "POINT", "sfg")), structure(c(279483.934794,
126848.066812), class = c("XY", "POINT", "sfg")), structure(c(279484.671745,
126846.168451), class = c("XY", "POINT", "sfg")), structure(c(279481.423421,
126849.762186), class = c("XY", "POINT", "sfg")), structure(c(279484.26992,
126849.201587), class = c("XY", "POINT", "sfg")), structure(c(279482.392713,
126847.815808), class = c("XY", "POINT", "sfg")), structure(c(279484.433132,
126848.781681), class = c("XY", "POINT", "sfg")), structure(c(279464.451565,
126851.480798), class = c("XY", "POINT", "sfg")), structure(c(279484.382978,
126847.365641), class = c("XY", "POINT", "sfg")), structure(c(279467.360089,
126852.300603), class = c("XY", "POINT", "sfg")), structure(c(279479.61541,
126849.09658), class = c("XY", "POINT", "sfg")), structure(c(279466.14978,
126852.559351), class = c("XY", "POINT", "sfg")), structure(c(279484.886854,
126847.868377), class = c("XY", "POINT", "sfg")), structure(c(279484.119702,
126847.161682), class = c("XY", "POINT", "sfg")), structure(c(279470.625807,
126852.693822), class = c("XY", "POINT", "sfg")), structure(c(279445.460584,
126850.649931), class = c("XY", "POINT", "sfg")), structure(c(279466.599221,
126851.342311), class = c("XY", "POINT", "sfg")), structure(c(279483.260098,
126846.444127), class = c("XY", "POINT", "sfg")), structure(c(279465.39646,
126851.578243), class = c("XY", "POINT", "sfg")), structure(c(279461.446417,
126851.685286), class = c("XY", "POINT", "sfg")), structure(c(279467.060466,
126851.315361), class = c("XY", "POINT", "sfg")), structure(c(279481.666825,
126847.166348), class = c("XY", "POINT", "sfg")), structure(c(279465.997014,
126851.952645), class = c("XY", "POINT", "sfg")), structure(c(279464.850045,
126852.084361), class = c("XY", "POINT", "sfg")), structure(c(279479.812024,
126849.716072), class = c("XY", "POINT", "sfg")), structure(c(279446.528814,
126849.413107), class = c("XY", "POINT", "sfg")), structure(c(279483.387615,
126848.617533), class = c("XY", "POINT", "sfg")), structure(c(279467.410871,
126852.647228), class = c("XY", "POINT", "sfg")), structure(c(279463.045599,
126851.092913), class = c("XY", "POINT", "sfg")), structure(c(279467.192462,
126850.610957), class = c("XY", "POINT", "sfg")), structure(c(279482.857071,
126846.589774), class = c("XY", "POINT", "sfg")), structure(c(279467.362675,
126853.431139), class = c("XY", "POINT", "sfg")), structure(c(279482.048481,
126846.644867), class = c("XY", "POINT", "sfg")), structure(c(279483.374352,
126849.372888), class = c("XY", "POINT", "sfg")), structure(c(279474.598772,
126851.767638), class = c("XY", "POINT", "sfg")), structure(c(279483.756836,
126847.842287), class = c("XY", "POINT", "sfg")), structure(c(279482.567311,
126849.302691), class = c("XY", "POINT", "sfg")), structure(c(279478.641653,
126850.870422), class = c("XY", "POINT", "sfg")), structure(c(279482.584101,
126848.925143), class = c("XY", "POINT", "sfg")), structure(c(279485.124647,
126849.512707), class = c("XY", "POINT", "sfg")), structure(c(279468.769474,
126850.634403), class = c("XY", "POINT", "sfg")), structure(c(279465.55247,
126851.777254), class = c("XY", "POINT", "sfg")), structure(c(279467.715807,
126852.224001), class = c("XY", "POINT", "sfg")), structure(c(279484.93287,
126849.113865), class = c("XY", "POINT", "sfg")), structure(c(279480.346107,
126850.045142), class = c("XY", "POINT", "sfg")), structure(c(279484.791499,
126845.99656), class = c("XY", "POINT", "sfg")), structure(c(279480.127622,
126849.258311), class = c("XY", "POINT", "sfg")), structure(c(279467.322434,
126853.021458), class = c("XY", "POINT", "sfg")), structure(c(279486.804416,
126848.35358), class = c("XY", "POINT", "sfg")), structure(c(279479.544454,
126850.434595), class = c("XY", "POINT", "sfg")), structure(c(279470.121986,
126853.850284), class = c("XY", "POINT", "sfg")), structure(c(279482.601255,
126848.578303), class = c("XY", "POINT", "sfg")), structure(c(279481.566547,
126847.214042), class = c("XY", "POINT", "sfg")), structure(c(279467.009571,
126851.380604), class = c("XY", "POINT", "sfg")), structure(c(279479.828672,
126848.274003), class = c("XY", "POINT", "sfg")), structure(c(279482.380271,
126850.493798), class = c("XY", "POINT", "sfg")), structure(c(279483.59185,
126846.991595), class = c("XY", "POINT", "sfg")), structure(c(279482.02476,
126847.51028), class = c("XY", "POINT", "sfg")), structure(c(279487.78452,
126846.968042), class = c("XY", "POINT", "sfg")), structure(c(279457.870443,
126849.984086), class = c("XY", "POINT", "sfg")), structure(c(279461.16455,
126849.963184), class = c("XY", "POINT", "sfg")), structure(c(279488.307303,
126845.539744), class = c("XY", "POINT", "sfg")), structure(c(279485.386716,
126848.442623), class = c("XY", "POINT", "sfg")), structure(c(279459.80964,
126851.036509), class = c("XY", "POINT", "sfg")), structure(c(279489.139433,
126845.779799), class = c("XY", "POINT", "sfg")), structure(c(279434.000227,
126853.71917), class = c("XY", "POINT", "sfg")), structure(c(279488.398219,
126845.904312), class = c("XY", "POINT", "sfg")), structure(c(279463.260793,
126852.27146), class = c("XY", "POINT", "sfg")), structure(c(279460.798162,
126851.031585), class = c("XY", "POINT", "sfg")), structure(c(279457.770687,
126849.800649), class = c("XY", "POINT", "sfg")), structure(c(279459.121238,
126850.63793), class = c("XY", "POINT", "sfg")), structure(c(279463.172401,
126852.817819), class = c("XY", "POINT", "sfg")), structure(c(279489.218588,
126846.103556), class = c("XY", "POINT", "sfg")), structure(c(279475.093668,
126850.922541), class = c("XY", "POINT", "sfg")), structure(c(279485.527982,
126847.860657), class = c("XY", "POINT", "sfg")), structure(c(279487.131018,
126848.017635), class = c("XY", "POINT", "sfg")), structure(c(279483.507056,
126849.00883), class = c("XY", "POINT", "sfg")), structure(c(279472.48728,
126852.42986), class = c("XY", "POINT", "sfg")), structure(c(279479.08314,
126848.543496), class = c("XY", "POINT", "sfg")), structure(c(279479.947657,
126848.028482), class = c("XY", "POINT", "sfg")), structure(c(279479.29483,
126848.473483), class = c("XY", "POINT", "sfg")), structure(c(279481.523654,
126848.576679), class = c("XY", "POINT", "sfg")), structure(c(279476.953854,
126850.595786), class = c("XY", "POINT", "sfg")), structure(c(279478.51345,
126849.139782), class = c("XY", "POINT", "sfg")), structure(c(279480.668225,
126848.242369), class = c("XY", "POINT", "sfg")), structure(c(279480.932874,
126847.654764), class = c("XY", "POINT", "sfg")), structure(c(279478.383989,
126848.108634), class = c("XY", "POINT", "sfg")), structure(c(279481.73884,
126850.835788), class = c("XY", "POINT", "sfg")), structure(c(279478.251508,
126852.58589), class = c("XY", "POINT", "sfg")), structure(c(279480.334514,
126848.239168), class = c("XY", "POINT", "sfg")), structure(c(279480.275468,
126852.22225), class = c("XY", "POINT", "sfg")), structure(c(279472.230346,
126852.358287), class = c("XY", "POINT", "sfg")), structure(c(279481.167625,
126850.781138), class = c("XY", "POINT", "sfg")), structure(c(279481.09048,
126847.210934), class = c("XY", "POINT", "sfg")), structure(c(279480.834739,
126851.757584), class = c("XY", "POINT", "sfg")), structure(c(279480.266324,
126850.307201), class = c("XY", "POINT", "sfg")), structure(c(279480.548103,
126847.687017), class = c("XY", "POINT", "sfg")), structure(c(279480.688103,
126849.937926), class = c("XY", "POINT", "sfg")), structure(c(279476.961619,
126848.248541), class = c("XY", "POINT", "sfg")), structure(c(279477.729186,
126851.805566), class = c("XY", "POINT", "sfg")), structure(c(279475.402826,
126850.56343), class = c("XY", "POINT", "sfg")), structure(c(279473.75986,
126851.276479), class = c("XY", "POINT", "sfg")), structure(c(279481.653266,
126851.727288), class = c("XY", "POINT", "sfg")), structure(c(279463.946761,
126853.503227), class = c("XY", "POINT", "sfg")), structure(c(279479.591367,
126852.104519), class = c("XY", "POINT", "sfg")), structure(c(279477.468634,
126851.690289), class = c("XY", "POINT", "sfg")), structure(c(279469.722892,
126851.433212), class = c("XY", "POINT", "sfg")), structure(c(279470.403465,
126849.918062), class = c("XY", "POINT", "sfg")), structure(c(279480.70051,
126851.457466), class = c("XY", "POINT", "sfg")), structure(c(279478.415813,
126848.985753), class = c("XY", "POINT", "sfg")), structure(c(279479.954161,
126852.142618), class = c("XY", "POINT", "sfg")), structure(c(279481.108743,
126847.296647), class = c("XY", "POINT", "sfg")), structure(c(279481.306497,
126851.107172), class = c("XY", "POINT", "sfg"))), class = c("sfc_POINT",
"sfc"), precision = 0, bbox = structure(c(xmin = 279430.398141,
ymin = 126845.539744, xmax = 279489.494214, ymax = 126855.779098
), class = "bbox"), crs = structure(list(input = "EPSG:31370",
wkt = "PROJCRS[\"BD72 / Belgian Lambert 72\",\n BASEGEOGCRS[\"BD72\",\n DATUM[\"Reseau National Belge 1972\",\n ELLIPSOID[\"International 1924\",6378388,297,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4313]],\n CONVERSION[\"Belgian Lambert 72\",\n METHOD[\"Lambert Conic Conformal (2SP)\",\n ID[\"EPSG\",9802]],\n PARAMETER[\"Latitude of false origin\",90,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8821]],\n PARAMETER[\"Longitude of false origin\",4.36748666666667,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8822]],\n PARAMETER[\"Latitude of 1st standard parallel\",51.1666672333333,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8823]],\n PARAMETER[\"Latitude of 2nd standard parallel\",49.8333339,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8824]],\n PARAMETER[\"Easting at false origin\",150000.013,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8826]],\n PARAMETER[\"Northing at false origin\",5400088.438,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8827]]],\n CS[Cartesian,2],\n AXIS[\"easting (X)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"northing (Y)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"Engineering survey, topographic mapping.\"],\n AREA[\"Belgium - onshore.\"],\n BBOX[49.5,2.5,51.51,6.4]],\n ID[\"EPSG\",31370]]"), class = "crs"), n_empty = 0L),
N = 1:256), row.names = c(NA, -256L), sf_column = "geometry", agr = structure(c(N = NA_integer_), levels = c("constant",
"aggregate", "identity"), class = "factor"), class = c("sf",
"tbl_df", "tbl", "data.frame"))
The difference between the df and the output
x <- st_as_sf(net, "nodes")
setdiff(df$N, x$N)
#>[1] 38 120
I found a way to answer my question by using a loop with while
. For that, first I create a function for extraction of the bent points, with the functions st_network_blend()
and st_as_sf()
from the sf
package.
distfn <- function(df){
net0 <- as_sfnetwork(Riv) |>
st_network_blend(df)
distances0e <- net0 %>% #group_by(Substation) %>% #'net' works better than 'new_network'
activate("nodes") %>%
st_as_sf() %>%
filter(!row_number() %in% c(1,2))
}
After, I created a function which will filter any non-bent points, gather the output with first bending operation and repeat the process if necessary.
Distloop <- function(df){
dist <- distfn(df)
Diff <- setdiff(df$N, dist$N)
x <- as.numeric(length(Diff))
if(as.numeric(length(Diff)) == 0){
dist
} else {
while(x != 0){
dfbis <- df %>% filter(N == Diff)
distb <- distfn(dfbis)
dist <- dist %>% rbind(distb)
Diff = setdiff(df$N, dist$N)
x <- as.numeric(length(Diff))
};
dist;
};
}
Distloop(df)
provide the correct amount of observation