pitfinder: Pit Finder in a Flow Dir SpatRaster for Watershed Extraction

pitfinderR Documentation

Pit Finder in a Flow Dir SpatRaster for Watershed Extraction

Description

find pits (depressions with no outlet )

Usage

## S4 method for signature 'SpatRaster'
pitfinder(x,filename="",...) 

Arguments

x

SpatRaster wih flow-direcion. See terrain

filename

character. Output filename

...

additional arguments for writing files as in writeRaster

Value

A SpatRaster-class (raster) map containing value 1 for the pits and value 0 elsewhere.

Author(s)

Emanuele Cordano

See Also

terrain,watershed,flowAccumulation,NIDP

Examples


## Creation of a Digital Elevation Model 

elev <- array(NA,c(9,9))
dx <- 1
dy <- 1 
for (r in 1:nrow(elev)) {
  x <- (r-5)*dx
  for (c in 1:ncol(elev)) {
    
    y <- (c-5)*dy
    elev[r,c] <- 10+5*(x^2+y^2)
    }
  } 
  
elev <- cbind(elev,elev,elev,elev) 
elev <- rbind(elev,elev,elev,elev) 
elev <- rast(elev)

## Flow Directions

flowdir<- terrain(elev,v="flowdir")
t(array(flowdir[],rev(dim(flowdir)[1:2])))

## Pit Detect

pits <- pitfinder(flowdir)

## Application wth example DEM

elev <- rast(system.file('ex/elev.tif',package="terra"))
flowdir <- terrain(elev,"flowdir")

pits <- pitfinder(flowdir)






terra documentation built on Oct. 14, 2024, 5:07 p.m.