topo.distance

0th

Percentile

Topographic distance

Calculates topographic corrected distance for a SpatialLinesDataFrame object

Usage
topo.distance(x, r, echo = FALSE)
Arguments
x

sp SpatialLinesDataFrame object

r

raster class elevation raster

echo

(FALSE/TRUE) print progress to screen

Value

Vector of corrected topographic distances same length as nrow(x)

Note

This function corrects straight-line (euclidean) distances for topographic-slope effect.

Aliases
  • topo.distance
Examples
# NOT RUN {
 library(sp)
 library(raster)
 library(GeNetIt)
 
 # create example data
 data(elev)
   r <- projectRaster(elev, res=c(1000,1000), 
                      crs="+proj=aea +lat_1=29.5 +lat_2=42.5")
   e <- extent(616893.6,714697.3,5001027,5080542)
     elev <- crop(r,e) 
       names(elev) <- "elev"
 pts <- sampleRandom(elev, 10, sp=TRUE)
   pts$ID <- LETTERS[seq( from = 1, to = nrow(pts) )]
   
 graph <- GeNetIt::knn.graph(pts, row.names=pts@data[,"ID"])
   proj4string(graph) <- proj4string(elev)
   head(graph@data)
  
 plot(elev)
   plot(graph, cex=0.5, add=TRUE)
   plot(pts,pch=19,col="red",add=TRUE)
 
 # Calculate topographical distance  
 ( tdist <- topo.distance(graph, elev) )
 
 # Increase in corrected distance
 tdist - graph$length
 
 # Percent increase in corrected distance
 ((tdist - graph$length) / graph$length) * 100

# }
# NOT RUN {
# }
Documentation reproduced from package spatialEco, version 1.3-2, License: GPL-3

Community examples

Looks like there are no examples yet.