Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAs after using wbt_fd8_flow_accumulation #75

Closed
alenahav opened this issue Apr 21, 2022 · 4 comments
Closed

NAs after using wbt_fd8_flow_accumulation #75

alenahav opened this issue Apr 21, 2022 · 4 comments

Comments

@alenahav
Copy link

Hi,
I am trying to use whitebox to calculate some hydrological characteristics of European DEM from https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1?tab=mapview.

I am using this raster:
class : RasterLayer
dimensions : 98, 250, 24500 (nrow, ncol, ncell)
resolution : 32800, 55200 (x, y)
extent : 952657.5, 9152658, 1029407, 6439007 (xmin, xmax, ymin, ymax)
crs : +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs
source : E20N10.tif
names : E20N10
values : 0, 804.12 (min, max)

dem <- "E:/Alenka/pracovni/olsiny_vegetace/vypocty/Present_data/E20N10.tif"
output <- "E:/Alenka/pracovni/olsiny_vegetace/vypocty/Present_data/E20N10_fill.tif"
wbt_fd8_flow_accumulation(dem, output)
fd8_flow_accumulation - **********************************************************************************

Finally, I have new raster but only with NAs:
class : RasterLayer
dimensions : 98, 250, 24500 (nrow, ncol, ncell)
resolution : 32800, 55200 (x, y)
extent : 952657.5, 9152658, 1029407, 6439007 (xmin, xmax, ymin, ymax)
crs : +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs
source : E20N10_fill.tif
names : E20N10_fill

values(d1)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[62] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA

Please, do you have some idea where is the problem?
Alena

@brownag
Copy link
Member

brownag commented Apr 25, 2022

Thanks for bringing up this issue, @alenahav.

First of all, there appears to be something unusual going on with the resolution of your raster... it is not the source of the problem but probably more aggregated than you intended.

resolution : 32800, 55200 (x, y)

Also, a very large portion of the DEM extent you use (952657.5, 9152658, 1029407, 6439007) contains no data (ocean).

I took a look at the source DEM and it seems that the following warning is issued when using E20N10.tif as input:

**********************************************************************************
WARNING: Interior pit cells were found within the input DEM. It is likely that the 
            DEM needs to be processed to remove topographic depressions and flats prior to
            running this tool.
**********************************************************************************

Unfortunately this more detailed output does not show up properly in {whitebox}... you get a set of asterisks instead of the elapsed time because the tool did not finish running and the output gets truncated as if it did. E.g.

fd8_flow_accumulation - **********************************************************************************

Running (for example) wbt_fill_depressions() before flow accumulation is sufficient to get the tool to run--but you will want to consider the "most appropriate" way to pre-process your DEM(s) for whatever your analysis may be--there are other options available in and out of WhiteboxTools. Getting everything to work well may require getting more specific about the areas/watersheds of interest to you.

library(terra)
#> terra 1.5.21
library(whitebox)

dem <- "D:/test_dem/eu_dem_v11_E20N10/eu_dem_v11_E20N10.TIF"
testarea <- "D:/test_dem/eu_dem_v11_E20N10/eu_dem_v11_E20N10_crop.tif"
input <- "D:/test_dem/eu_dem_v11_E20N10/filled_dem.tif"
output <- "D:/test_dem/eu_dem_v11_E20N10/flow_accumulation.tif"

# sf::gdal_utils(source = dem)

r <- rast(dem)
r2 <-  crop(r, ext(2850000, 2900000, 1860000, 1900000))
writeRaster(r2, testarea, overwrite = TRUE)

wbt_fill_depressions(testarea, input)
wbt_fd8_flow_accumulation(input, output)
plot(log10(rast(output)))

Hopefully this gets you on the right path. I will make some changes to how tools are run to preserve WARNING output if generated so in the future you get the needed guiding messages.

@brownag
Copy link
Member

brownag commented May 6, 2022

I think I have figured out a way to display these warnings while still hiding the bulk of tool output in #77.

However, after looking into this more, I am going to revise what I said. @alenahav. I think the large amount of NoData in your raster combined with aggregation very coarse resolution is the reason you are getting NA values in your result raster. The FD8FlowAccumulation tool runs despite the warning being issued; the warning is to be suspicious of the results if pits have not been filled. I will close this issue but feel free to comment back if you are having trouble getting resolution sorted out.

@brownag brownag closed this as completed May 6, 2022
@alenahav
Copy link
Author

alenahav commented May 6, 2022

Thank you for your response. I noticed that NAs are only in oceans and for land the calculation works. My coarse resolution is because that I need the same resolution as the other environmental layers that I use in modelling. Do you think there are still problem that pits have not been filled for this coarse resolution (one raster cell is around 50 km)?

Alena

@brownag
Copy link
Member

brownag commented May 6, 2022

Well, the source raster had a resolution of 25m if I remember correctly. That is like 2000x aggregation... I am not sure whether that is in the typical scope of this tool/what the warnings are referring to. If it were me I would probably try to summarize the flow accumulation results from a somewhat more detailed DEM, even if I needed to be aggregating up, but I do not know what your work is focusing on.

At that resolution you are going to be looking at something like a broad regional average, and I would be a more concerned about, for example, the aggregation of grid cells that contain large amounts of NoData along the complex coastline. "Pits" would still potentially be an issue numerically speaking; of low spots in the grid dictating how flow accumulates but perhaps not as much because you will be essentially averaging out a lot of the variation... but perhaps more if those low spots are artifacts of aggregation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants