From 288dc8b0fcf349597c686401a5bbd77cf885f37c Mon Sep 17 00:00:00 2001 From: Josie Hughes Date: Fri, 15 Mar 2024 17:19:22 -0400 Subject: [PATCH] more fiddling --- R/getGraph.R | 1 + R/weightFunctions.R | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/R/getGraph.R b/R/getGraph.R index 96ab55c..805ad78 100644 --- a/R/getGraph.R +++ b/R/getGraph.R @@ -26,6 +26,7 @@ getGraph<- function(sim, neighbourhood,method="old",weightFunction = function(x1 #sim = list(costSurface=costRaster);neighbourhood="octagon" #gdistance method takes more time and less memory. See testAltGraphFns in RoadPaper repo for details. resolution=res(sim$costSurface)[1] + e = new.env() if(method=="gdistance"){ if(!is.element(neighbourhood, c("rook", "octagon","queen"))) { stop("neighbourhood type not recognized") diff --git a/R/weightFunctions.R b/R/weightFunctions.R index 1371010..369b2f1 100644 --- a/R/weightFunctions.R +++ b/R/weightFunctions.R @@ -19,7 +19,7 @@ #' @param limitCost Value assigned to edges that exceed the grade limit. Set to a high (not NA) value if #' @export slopePenaltyFn<-function(x1,x2,baseCost = 16178,limit=20,penalty=504,limitCost=NA){ - if(!exists("resolution")){resolution=1} # Will use value from calling environment if it exists there. + if(!exists("e$resolution")){resolution=1}else{resolution=e$resolution} # Will use value from calling environment if it exists there. #If one of the nodes is a road or barrier ignore grade penalty cond = pmin(x1,x2)>0 cond[is.na(cond)]=F