-
Notifications
You must be signed in to change notification settings - Fork 79
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
UFRM: incorrect ValueError raised if biophysical table includes a row of all 0s #1123
Comments
This came up again on the forums and I was writing a new issue when I discovered this one existed. Here's what I was writing: I think we've mostly settled on being able to support raster inputs that do not have a defined # Even without an IndexError, still must guard against
# lucodes that can index into the sparse matrix but were
# missing from the biophysical table. They have rows of all 0.
if not cn_matrix.sum(1).all():
empty_rows = numpy.where(lucode_to_cn_table.sum(1) == 0)
missing_codes = numpy.intersect1d(valid_lucodes, empty_rows)
raise ValueError(
f'The biophysical table is missing a row for lucode(s) '
f'{missing_codes.tolist()}') This logic doesn't allow for a user entered row of all 0 values, which end up being caught as that rows Forum link: https://community.naturalcapitalproject.org/t/urban-flood-risk-mitigation-model-area-of-analysis/3583/8 |
This came up on this forum post.
As is somewhat common, a LULC raster without a nodata value was used. But the raster was filled with 0s that probably represent nodata (or maybe water), and so the biophysical table was given a row for
lucode 0
, filled with 0s forCN_A, CN_B, CN_C, CN_D
.I don't know the details of this model, and whether setting those parameters to 0 is equivalent to setting that pixel value to nodata, but I don't think it matters.
Here's the problem
This model does fancy things using a sparse matrix as a lookup table for these CN values. Such a matrix can appear to have a row full of 0s for two different reasons:
The text was updated successfully, but these errors were encountered: