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

Reclass: 'max' and 'nodata' as valid values #315

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jfbourdon
Copy link
Contributor

Additional fix for #67 and #90.

Usage of max was already allowed, but with the current implementation, le maximal value itself would always be excluded from the reclassification. I think we can safely assume that if a one uses max, the intent is to include it in the reclassification. So I chose to add 0.1 to the maximal value to make sure that the original value would be included in the class. I choose 0.1 instead of 1 thinking that if the input is a Uint8 with a NoData value of 255 and a max value of 254, we don't want to rewrite the NoData cells in the process.

I also implemented the nodata string as a valid value. It was simply forgotten in the initial fix.

@jfbourdon
Copy link
Contributor Author

jfbourdon commented Jan 10, 2023

Looking at this again I realise this tool cannot rewrite a NoData cell so my precaution is superfluous. I suppose that if someone want to reclass the NoData cells, the person can just run ModifyNoDataValue or ConvertNodataToZero before Reclass.

I also realise also that if someone wants to the max value also as a new value, my fix will put a max + 0.1 instead of just max. The position of 'max' inside the whole reclass string would need to be checked to avoid this. Also if the max value is used in assigned mode it won't update the value.

I'll rework this.

@jfbourdon
Copy link
Contributor Author

This shouldn't cause any issue now when using max as a new value or when using assign_mode. An alternative fix would be to directly change < for <= on lines 316 and 322 when a new switch like --include_last is provided and that it's the last class being evaluated.

if z >= reclass_vals[prev_idx * 3 + 1]
&& z < reclass_vals[prev_idx * 3 + 2]
{
z = reclass_vals[prev_idx * 3];
} else {
for a in 0..num_ranges {
if z >= reclass_vals[a * 3 + 1]
&& z < reclass_vals[a * 3 + 2]
{

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

Successfully merging this pull request may close these issues.

1 participant