NOAA-OWP / hydrofabric

hydrofabric meta-package
https://noaa-owp.github.io/hydrofabric/
MIT License
26 stars 7 forks source link

Land cover and soil classification using generic categories #35

Open SnowHydrology opened 5 months ago

SnowHydrology commented 5 months ago

Current behavior

The hydrofabric determines the land cover classification for a basin by using the mode of land cover categories within its boundaries. Sometimes this leads to conflicts with the soil type, particularly if water is involved.

The below screenshot, from @mikejohnson51, shows an area in which the soil (ISLTYP = 14) is classified as water, while the land cover (IVGTYP = 15) is classified as mixed forest.

image

This caused runs of Noah-OWP-Modular to fail because of inconsistencies in the soil and land cover categories: https://github.com/NOAA-OWP/DMOD/issues/472#issuecomment-1893759701

Expected behavior

The hydrofabric should return self-consistent values of soil and land cover.

Suggested changes

Add new, lumped generic categories for soil and land cover. I provide suggestions below:

Soil generic categories

From the STAS category in Noah-OWP-Modular:

land = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19)
water = 14
ice = 16

Land cover generic categories

From the USGS category in Noah-OWP-Modular:

urban = 1
agricultural = c(2, 3, 4, 5, 6)
grassland = c(7, 8, 9, 10)
forest = c(11, 12, 13, 14, 15)
water = 16
wetland = c(17, 18)
barren = c(19, 25, 26, 27)
tundra = c(20, 21, 22, 23)
ice = 24

Code changes

Implement a two-step classification option that:

  1. Provides generic category mapping as shown above
  2. Computes the mode of all generic land cover (e.g., forest, water, urban, agriculture) and soil categories in the basin
  3. Then computes the mode (using the specific land cover and soil categories) of the dominant generic categories from step 2
  4. Then checks for internal consistency between soil and land cover categories. The most important check is that if soil == land then the land cover corresponds to land_cover %in% c(urban, agricultural, grassland, forest, wetland, barren, tundra) or soil == water and land_cover == water or soil == ice and land_cover == ice
mikejohnson51 commented 5 months ago

@SnowHydrology Working through this and am close... however there is something odd... the chance I did something wrong is not 0 but this is what I am seeing:

In the SOIL map (ISLTYP) there appears to be a glacier in Florida. I changed values of 16 (ice) to 100 just to be visually nice.

Does this bother any of you haha?

library(hydrofabric)

wrf  = correct_nwm_spatial('/Volumes/MyBook/conus-hydrofabric/nwm_v3.0.7/conus/wrfinput_CONUS.nc')

AOI = AOI::aoi_get(state = "FL")

crop(wrf[['ISLTYP_Time=1']], project(vect(AOI), crs(wrf))) %>% 
  classify(data.frame(from = 16, to = 100)) %>% 
  plot()

Created on 2024-02-07 with reprex v2.0.2

mikejohnson51 commented 5 months ago

Yeah .... the code is good. That cluster of 16 is there for sure:

image

SnowHydrology commented 5 months ago

Hmm, any chance they're using a different soil classification than our SOILPARM.TBL?

The public WRF-Hydro version shows the same table, but maybe operational version is different.

mikejohnson51 commented 5 months ago

I dont think so, it is surrounded by 4 (SILT LOAM) ,6 (SILT) ,13 (ORGANIC MATERIAL). Which seem reasonable.

And if I do the same with CONUS (Ice becomes 100 for visibility) its generally reasonable but definitely has some questionable areas.

image

SnowHydrology commented 5 months ago

I'd say that is generally unreasonable.

Is there something we're missing or is this a problem?

mikejohnson51 commented 5 months ago

I am confident that in the wrfinput associated with NWM 3.0.7, those are where class 16 exists. I only have found tables where class 16 is (OTHER; INLAND ICE).

Someone in GID thought it might be a model hack...

mikejohnson51 commented 5 months ago

However! If we were to rebuild landcover and soil grids this is a good time to inplement some of @DonnyDHKim and my work on land cover resampling:

An area preserving method for improved categorical raster resampling

Untangling the impacts of land cover representation and resampling in distributed hydrological model predictions