ncss-tech / soilDB

soilDB: Simplified Access to National Cooperative Soil Survey Databases
http://ncss-tech.github.io/soilDB/
79 stars 19 forks source link

move WCS specs to hosted JSON files #347

Open dylanbeaudette opened 2 months ago

dylanbeaudette commented 2 months ago

The FY24 gNATSGO mukey grid was incorrectly exported as INT32 vs. UINT32, with NODATA encoded as -2147483648. WCS specifications are hard-coded in soilDB, but should be hosted server-side, ideally in a JSON file for each suite of WCS variables.

I'll work on making the JSON files on soilweb, then make changes here.

Accidentally found an INT32 NODATA in ND.

library(terra)
library(soilDB)
library(sf)

# https://casoilresource.lawr.ucdavis.edu/gmap/?loc=48.01037,-98.31562,z15
bb <- '-98.3466 47.9967,-98.3466 48.0232,-98.2844 48.0232,-98.2844 47.9967,-98.3466 47.9967'

## assemble AOI polygon into WKT
wkt <- sprintf('POLYGON((%s))', bb)

## init sf polygon
# WGS84 GCS
x <- vect(wkt, crs = 'epsg:4326')

gnatsgo <- mukey.wcs(x, db = 'gNATSGO', res = 30)
rss <- mukey.wcs(x, db = 'rss', res = 30)

# RAT has a bogus entry, due to INT32 coded NA value (-2147483648)
head(cats(gnatsgo)[[1]])

# note single pixel with bogus NA
par(bg = 'red')
plot(gnatsgo)

# what about the little missing pixel, does it exist in RSS?
plot(rss)

# what is going on with that little pixel?
plot(gnatsgo - rss)
dylanbeaudette commented 2 months ago

Also, it seems that the grid system has changed from FY23 → FY24.

image