0

I have 84 1-m resolution DEM files (~1.2GB each saved as .asc files) across a large area (~10,000 square km) and would like to calculate TWI. For each tool (i.e. FillDepressions, Slope, D8FlowAccumulation and TWI) I am looping over sequential files one by one but some of my outputs are not picking up rivers and streams where they should be.

How does Whitebox deal with the edges when looping over multiple different files? Must I mosaic the tiles first to ensure hydrological connectivity between tiles?

rL <- list_files_with_exts("input_filepath", "tif", full.names = TRUE)
outFolder <- "output_filepath"

for(i in 1:length(rL)){
  
  rLs <- rL[i]
  
  outn <- paste(outFolder, gsub(".*/", '', rLs), "_", "sca", ".tif", sep = "")

  wbt_d8_flow_accumulation(
    input = rLs,
    output = outn,
    out_type = 'specific contributing area',
    log = FALSE,
    clip = FALSE,
    pntr = FALSE,
    esri_pntr = FALSE,
    wd = NULL,
    verbose_mode = FALSE
  )
  
  print(paste(i, length(rL)))
  
}
3
  • Pleae define "TWI".
    – Stu Smith
    Mar 12, 2021 at 0:58
  • @StuSmith Topographic Wetness Index, its a measure of how much water a point might get from its catchment divided by how quickly it might drain that water because of its slope.
    – Spacedman
    Mar 12, 2021 at 11:22
  • In Whitebox it is called "wetness index".
    – xtina
    Mar 16, 2021 at 3:04

1 Answer 1

0

If you are running independent analyses on tiles then whatever tool you are using can only see to the edge of the tile. This means for a flow accumulation algorithm, if the catchment hits the edge of the tile then that flow will not get the full flow accorded it from the catchment in the other tiles.

If you don't know the size of your catchments then you may have to mosaic all your DEMs and then do flow accumulation. If you do know the size of your catchments, and none of them are much bigger than a single tile, then it might only be necessary to make a 3x3 mosaic to compute the flow accumulation (and hence TWI) for the central tile.

I don't know if anyone has implemented a tiled flow accumulation algorithm, where for each tile it would compute the accumulations at the points and also the flows off the edges, such that to compute the flows on neighbouring tiles those flows could be added to the neighbouring cell edges...

If mosaicing your files creates a DEM too large for your computer, try resampling down by a factor of 10 or 100 or so to get something that works and assess whether that is accurate enough for your analysis question.

Another solution, assuming Whitebox uses GDAL to access raster data, is to construct a GDAL VRT file that creates a "virtual" mosaic without you having to create a single large raster file.

2
  • Thanks, this is good advice, I will try the VRT. Is there a way to take advantage of multiple cores for extra processing power? I have 8 cores and have used parallel processing through LidR but nothing else.
    – xtina
    Mar 16, 2021 at 3:07
  • I realized it was not exactly the edges I was having issues with, rather, it was the high-resolution 1m DEM. When I ran "fill" or "breach" pits, it would fill in everything. I resampled all my files to 10m (allowing me to bypass the breaching step since there are not likely to be any artifacts remaining) and will mosaic them into one big raster as you suggested.
    – xtina
    Mar 16, 2021 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.