Calculate wall-to-wall predictions #683
-
Good morning, I was trying to create a raster indicating the predicted tree volume. Instead of using "predict" commands after generating metrics (~stdmetrics), I made a function based on the modeling works. So, I wrote my code below f1=function(X,Y, Z, Intensity, ReturnNumber,Classification) {
ans = stdmetrics(X,Y,Z,Intensity,ReturnNumber,Classification,dz=1, zmin=0)
volume = -2.242733 + 0.02058904 * ans$pzabove2 - 0.506878 * ans$zq5 - 0.9774944 * ans$zq15 + 0.003733993 * ans$zq40 + 0.0570145 * ans$zq95 - 0.008179027 *ans$zpcum6 + 0.00002636796 * ans$isd - 0.1198544 * ans$ikurt + 0.05262075 * ans$ipcumzq90 + 0.02805897 * ans$p2th + 0.01136718 * ans$p3th
vol = 10^(volume)
return(vol)
}
prediction1 <- pixel_metrics(lasnorm, ~f1(X,Y, Z, Intensity, ReturnNumber,Classification), 20) # predicting model mapping
plot(prediction1, col = height.colors(50)) # some plotting However, the value of it is too low to believe it is as stand volume. Therefore, I would like to follow the instruction found in here (https://r-lidar.github.io/lidRbook/modeling-aba.html). ###Statistical modeling
Dat_vol_new <- read.csv("Tin_1_edit.csv")
dummies <- dummyVars(TotalVolume ~ ., data = Dat_vol_new)
train_dummies = predict(dummies, newdata = Dat_vol_new)
x = as.matrix(train_dummies)
y = Dat_vol_new$TotalVolume
lasso_model<- glmnet(x, y, alpha = 1, lambda = 0.01584893, standardize = TRUE)
###Wall to wall modeling and predictions
metrics <- pixel_metrics(lasnorm, ~stdmetrics(X,Y,Z,Intensity,ReturnNumber,Classification,dz=1, zmin=0), 20)
vol<-predict(metrics, lasso_model)
plot(vol, col = height.colors(50)) but it gave me an error message
Could you please help me to create wall-to-wall prediction map? Bests, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I can't help. I don't know what is |
Beta Was this translation helpful? Give feedback.
I can't help. I don't know what is
Dat_vol_new
I don't know what isdummyVars
. Please provide a minimal reproducible example or at least a minimal amount of information on your data.