Introduction

...

Overview of features

Load libraries

library(SiteExploitationTerritories)

Loading Data

dem <- raster("../data/SET_SRTM90.asc")
crs(dem) <- CRS('+init=EPSG:31467')
slope = ''
pts <- SiteExploitationTerritories::pts

If necessary: croping the DEM using the buffer()-function

The DEM will be cropped to an extent of 5 km around the sites.

dem.croped <- BufferCrop(pts = pts, dem = dem, extent = 5)
plot(dem.croped)

Using the Site Exploitation Territories Function

# Create Environment for multi-core computation
library(doParallel)
library(parallel)
cl <- makeCluster(detectCores() - 1)
print(cl)
registerDoParallel(cl)
start.time <- Sys.time()
a <- SiteExploitationTerritories(pts = pts,
                                dem = dem,
                                slope = slope,
                                epsg = 31467)
end.time <- Sys.time()
time.taken <- end.time - start.time
time.taken
# view the output
site <- 1

plot(a[[site]][[1]]) #  plot the Time-Cost Raster
plot(a[[site]][[2]], add = TRUE) # plot the Contour Lines

Save the output

for (i in 1:length(a)) {
  TCR = paste("../../output/Site", i, "TimeCostRaster", sep = "_")
  CTL = paste("../../output/Site", i, "ContourLines", sep = "_")
  rdt = "ascii"

  writeRaster(a[[i]][[1]], TCR, format = rdt, overwrite = TRUE) # write time cost raster
  shapefile(a[[i]][[2]], filename = CTL, overwrite = TRUE) # write contourlines shapefile
}


eScienceCenter/SpArchR documentation built on May 9, 2019, 2:26 p.m.