r-lidar-lab / ALSroads

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

Error in `names<-`() bug? #20

Closed ilythiamorley closed 2 years ago

ilythiamorley commented 2 years ago

Hi JR,

I updated the MFFProads package this morning and I am getting an error when using MFFProads::measure_road and MFFProads::measure_roads. I have included the error below and a link to example data.

param = mffproads_default_parameters
param$extraction$road_buff = 50
corrected_road <- MFFProads::measure_road(road = road, ctg = ctg, dtm = dtm, water = water, param = param)
#> Progress: ...........
#> Error in `names<-`(`*tmp*`, value = c("slope", "roughness", "conductivity_slope",  : incorrect number of layer names

Thank you for the help

Example data: https://drive.google.com/drive/folders/1UQpihlZUsB3fahuLYB1FQ7ODqImgCx_E?usp=sharing

Jean-Romain commented 2 years ago

The link points to the same dataset than the one you sent me yesterday (I don't know if it is expected).

I ran the code and it worked. I cannot reproduce. Please provide a minimal reproducible example

ilythiamorley commented 2 years ago

I was testing on the same dataset, which I indexed to correct the missing lax files.

However, I have made a new DTM using two 500m tiles and isolated a different road segment to ensure that the issue is not related to the data. I still get the same error. My code is:

las_infolder <- "D:/example_data/LAZ"
ctg <- readLAScatalog(las_infolder, filter = "-drop_withheld -keep_random_fraction 0.25")
dtm <- raster("D:/example_data/dtm/dtm.tif")
road <- st_read("D:/example_data/roads/road.shp")

param = mffproads_default_parameters
param$extraction$road_buff = 50
corrected_road <- MFFProads::measure_road(road = road, ctg = ctg, dtm = dtm, water = NULL, param = param)

New data: https://drive.google.com/drive/folders/1Au8DxDsONqSkCkvSVqBDrk6ZX2iNPlUn?usp=sharing

Cheers, L

Jean-Romain commented 2 years ago

So you have the error for all roads?

ilythiamorley commented 2 years ago

Yes, I cannot run the function MFFProads::measure_road() on any roads without getting this error.

Jean-Romain commented 2 years ago

Try to reinstall. If it does not solve the problem I'll test on windows tomorrow.

ilythiamorley commented 2 years ago

I have reinstalled but got the same error. I have also tested on a different computer where I installed MFFProads for the first time, but also the error.

Jean-Romain commented 2 years ago

That leave me clueless... Does the example from the doc works? If not it will be easier to reproduce with that. And if it does not work please run it with :

options(MFFProads.debug.verbose = TRUE)
options(MFFProads.debug.progress = FALSE)

So we will better see where the error occurs

Extracting the point cloud...
Processing [===================================] 100% (4/4) eta:  0s
Creating a spatial index...
Computing conductivity maps...
   - Slope conductivity map in 0.05s 
   - Roughness conductivity map in 0.08s 
   - Sobel conductivity map in 0.2s 
   - Intensity conductivity map in 0.22s 
   - CHM conductivity map in 0.16s 
   - Bottom layer conductivity map in 0.22s 
   - Density conductivity map in 0.4s 
   - Global conductivity map in 0.06s 
Computing conductivity masks...
   - Aggregation and masking in 0.29s 
   - Road rasterization and distance factor map in 0.32s 
   - Add full conductivity end blocks in 0.3s 
Computing graph map...
   - Transition graph in 0.9s 
   - Geocorrection graph in 0.13s 
Computing least cost path...
Computing road metrics... 100%
Estimating the state of the road...
   - Estimated probability based on vegetation: 100 
   - Estimated probability based on road size: 100 
   - Estimated probability based on conductivity: 100 
   - Estimated probability based on road shoulders: 100 
   - Estimated probability: 100 
Done
Jean-Romain commented 2 years ago

I suddenly realized what was the problem. I was not using the same version of lidR than you. It is fixed now. Sorry for the time lost