2017-06-17 71 views
0

我正在嘗試創建無法通過最低成本路徑穿過的障礙(河流)。最低成本路徑障礙(R)(gdistance)

我創建了一個使用「地區」的過渡圖層,其中包含陸地和河流上的過渡值。然而,障礙物周圍存在「緩衝」,價值增加,而不是離散的障礙。

成本柵格和過渡層 cost raster Transition layer 如可以看到的,有一個「緩衝」圍繞在過渡層的勢壘。

有關如何創建離散邊界的任何想法?最好是屏障值爲1000,其他值爲1.

謝謝!

代碼: library(gdistance) ## Create cost surface where "land" exists in the middle cost <- raster(nrow=100, ncol=100, xmn=0, xmx=100, ymn=0, ymx=100, crs="+proj=utm") cost[] <- 10 cost[cellFromRowColCombine(cost, 50:55,20:80)] <- 1000 costf <- asFactor(cost < 100) ## Produce transition matrices, and correct because 8 directions trCost <- transition(costf, "areas", directions=16) trCost1 <- geoCorrection(trCost[[2]], type="c") plot(cost) plot(raster(trCost[[1]]))

+0

我在這裏回答了這個問題:HTTPS ://gis.stackexchange.com/questions/244364/least-cost-path-barrier-r-gdistance/244447#244447 – JacobVanEtten

回答

0

我建議你定義你真正的障礙,因爲NA值,而不是高值,其概率始終是可能的:

library(gdistance) 

## Create cost surface where "land" exists in the middle 
cost <- raster(nrow=100, ncol=100, 
       xmn=0, xmx=100, ymn=0, ymx=100, crs="+proj=utm") 
cost[] <- 10 
cost[cellFromRowColCombine(cost, 50:55,20:80)] <- NA 
costf <- asFactor(cost < 100) 
## Produce transition matrices, and correct because 8 directions 
trCost <- transition(costf, "areas", directions=16) 
plot(cost) 
plot(raster(trCost))