invest: raster masking gives unexpected output if nodata is nan
There have been a few user forum posts recently that have caused issues because the users input raster had a nodata value of nan
. Should checking / warning of nan
nodata values be a part of UI validation? Or a part of model validation? Or both?
The recent forum post where this came up: https://community.naturalcapitalproject.org/t/no-data-value-ndr-model/2345/7
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (21 by maintainers)
Commits related to this issue
- I. #738 AWY isclose equal nan — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 carbon isclose equal nan — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 cbc isclose equal nan — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 cv isclose equal nan — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 crop reg isclose equal nan — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 AWY use utils func — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 carbon use utils func — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 use utils nodata check — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 change func name — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 add tests — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 update history — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738, revert malformed line ending files — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 swap utils func back in — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 fix cbc search replace bug — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 update the func name — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 update history — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 update test class name — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 replace ==/!= nodata comparison — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 fix fce masking bug — committed to dcdenu4/invest by dcdenu4 3 years ago
- I. #738 fix syntax bug in SWY — committed to dcdenu4/invest by dcdenu4 3 years ago
this might complicate things 😕
Dang, the
nan
case is an interesting one.I wonder if it’s worth coming back to an idea that @emlys had some time ago: would it be worth having a
utils
function to compare nodata values? We now have a couple interesting reasons why such a function might be worth it:nan
case, requiring that we remember to pass an extra parameter tonumpy.isclose
every time we use it in theraster_calculator
context and we have a user-defined nodata valuea != b
) is noticeably faster in numpy thannumpy.isclose(a, b)
, but we can only do integer comparison on integer datasets and sometimes users provide a floating-point LULC so it’s a gamble to rely on integer equality.nan
comparison in hypothesis-based testing later onA centralized implementation of this might be as simple as
We have one other example of a code snippet we use basically everywhere in
utils.make_suffix_string
, so maybe this would make sense for us? I’m curious what everyone thinks.