Commit 17e533d3 authored by de Lavenne Alban's avatar de Lavenne Alban
Browse files

fix: managing units

the bug appears on CRAN when updating dependencies
parent a5307321
No related merge requests found
Showing with 3 additions and 2 deletions
+3 -2
......@@ -104,12 +104,13 @@ hdist.sfc <- function(x, y, method="rghosh", gres=5, ditself=FALSE, maxsample=2.
gdist <- loop_gdist(xdisc=xdisc, ydisc=ydisc, proj=proj, intersect=FALSE, parallel=parallel[2], cores=cores[2])
if(ditself){
if(verbose) cat("Computing Ghosh distance within catchments\n")
na_val <- set_units(NA, units(gdist), mode="standard")
if(!identical(x,y)){
gdist <- cbind(gdist,sapply(xdisc,FUN=function(x){call_gdist(pts1=x, pts2=x, proj=proj, intersect=FALSE, rescale=FALSE, diag=TRUE, parallel=parallel[2], cores=cores[2])}))
gdist <- rbind(gdist,c(sapply(ydisc,FUN=function(x){call_gdist(pts1=x, pts2=x, proj=proj, intersect=FALSE, rescale=FALSE, diag=TRUE, parallel=parallel[2], cores=cores[2])}),NA))
gdist <- rbind(gdist,c(sapply(ydisc,FUN=function(x){call_gdist(pts1=x, pts2=x, proj=proj, intersect=FALSE, rescale=FALSE, diag=TRUE, parallel=parallel[2], cores=cores[2])}),na_val))
}else{
gdist <- cbind(gdist,diag(gdist))
gdist <- rbind(gdist,c(diag(gdist),NA))
gdist <- rbind(gdist,c(diag(gdist),na_val))
}
units(gdist) <- units(st_distance(xdisc[[1]][1],ydisc[[1]][1])) #units are lost by some operations
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment