I need to create a landscape resistance map based on path level spatial randomisation, as I have read in some research papers. Are there tools for this? I need to randomly shift and rotate the the utilised path I have to create available paths with identical spatial topology. I then need to compare the distribution of utilised path with avialable paths from each landscape resistant factor to determine resistance values.
Here is some R code. The paper says that they randomly shifted the path. I take that to mean they randomly shifted each node of the path. They say that the path was shifted between 0 and 30 but I think that it only makes sense to shift between -30 and 30.
taking advantage of center of gravity rotation in the maptools package
library(sp) library(maptools) #create the nodes of a spatiallines object set.seed(2) path.mat<-matrix(c(seq(1,60,3),(seq(1,60,3))+ceiling(abs(rnorm(60)*5))),ncol=2) path<-Lines(list(Line(path.mat)),ID="p") #randomly shift nodes between 0 and 30km shiftx<-sample(seq(-30,30,0.01),nrow(path.mat)) shifty<-sample(seq(-30,30,0.01),nrow(path.mat)) npath.mat<-cbind(path.mat[,1]+shiftx,path.mat[,2]+shifty) npath<-Lines(list(Line(npath.mat)),ID="np") npathSL<-SpatialLines(list(npath)) #randomly rotate between 0 and 360 degrees npath.rot<-elide(npathSL,rotate=sample(seq(0,360,0.01),1),center=apply(bbox(npathSL),1,mean)) npath.rot.mat<-coordinates(npath.rot)[][] npath.rot<-Lines(list(Line(npath.rot.mat)),ID="npr") npath.alllines<-SpatialLines(list(path,npath,npath.rot)) plot(npath.alllines,col=c("black","red","green"))