r-lidar-lab / ALSroads

Road corrections and measurements from ALS data
19 stars 4 forks source link

Corrected road nodes order reversed from original road #62

Closed jfbourdon closed 1 year ago

jfbourdon commented 1 year ago

For some roads, the resulting road is flipped relative to the orientation of the input road. This cause an issue when checking for anomalies with check_road_differences() as their respective startpoint and endpoint of both lines are falsely very far appart.

Data: https://transfert.mffp.gouv.qc.ca/?ShareToken=7CC2BD611B50E2D04CB6E05E9474D0397DA39551 Tested with ALSroads d39fc2c

library(ALSroads)
library(lidR)
library(raster)

ctg <- readLAScatalog("point_cloud.laz")
dtm <- raster("dtm.tif")
road <- sf::st_read("line.gpkg")

corrected_road <- measure_road(road, ctg = ctg, dtm = dtm)

plot(road$geom, col="red")
coord <- sf::st_coordinates(road$geom)[c(8,12),1:2]
arrows(coord[1,1], coord[1,2], coord[2,1], coord[2,2], col="red", lwd=4)
plot(corrected_road$geom, add=T, col="blue")
coord <- sf::st_coordinates(corrected_road$geom)[8:9,1:2]
arrows(coord[1,1], coord[1,2], coord[2,1], coord[2,2], col="blue", lwd=4)

# Checking differences with original road
check_road_differences(corrected_road, road, "primaryindex")  # really different from orignal line
#   primaryindex area_over_perimeter      P50     P90     P100  end_max
# 1        58762            3.635277 238.2542 420.677 451.2766 451.2766

check_road_differences(sf::st_reverse(corrected_road), road, "primaryindex")  # rather close from orignal line
#   primaryindex area_over_perimeter      P50      P90     P100  end_max
# 1        58762            3.635277 6.946467 22.21269 25.11234 5.723174

image

Jean-Romain commented 1 year ago

Corrigé, l'autre bug c'était le même problème

jfbourdon commented 1 year ago

Merci. Peux-tu pousser le commit aussi sur la branche principale? Je ne sais si c'était voulu, mais présentement, c'est seulement sur _driveroad.

Jean-Romain commented 1 year ago

C'est fait désolé. Je sais même plus c'est quoi la différence entre main et drive_road

jfbourdon commented 1 year ago

Merci. Je pense que tu avais fait _driveroad quand tu as commené à expérimenter avec la navigation à partir d'un point. Avant que tu ne crées vecnet en bonne et due forme dans le fond.

Jean-Romain commented 1 year ago

Je crois que dans drive_road J'ai pas mal changé la fonction de conductivité pour avoir un meilleur output pour vecnet (qui ne calcul pas la conductivité). Sauf que je ne peux pas merger au risque de casser l'évaluation de l'état de la route puisque la conductivité version 1 est utilisée