-
Notifications
You must be signed in to change notification settings - Fork 177
i.zero2null: fix nodata handling if nodata-border is already present #506
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
Conversation
|
May this PR be merged? |
metzm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I did not encounter this case in my tests, please merge!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the fix in this PR is not correct. i.zero2null must be used before reprojection to avoid artefacts at the transitions from zero to non-zero cells. In this example, i.zero2null is used after reprojection (from UTM zone 31 to UTM zone 30), this is too late, artefacts have already been introduced.
A proper fix would be to check if there are both NULL and zero cells in the input image (with e.g. r.info -s, if yes, exit with a warning like "Sorry, too late, the input image has already been reprojected".
|
A good place for this zero2null method would be |
See also: |
|
Thanks @metzm, I now understand the correct processing order. I agree it would be better to optionally put |
|
@griembauer pls rebase this PR to the (new) |
|
This PR can be closed as the fix should be added to |
This PR fixes the following issue in
i.zero2null:Bug description
In some cases,

i.zero2nullresults in blurred (=extrapolated) image borders where null() should be. This occurs if there already is a nodata-border in the input map. An example of a Sentinel-2 scene processed withi.zero2null:to reproduce
S2A_MSIL2A_20210329T105631_N0214_R094_T31UCV_20210329T134554(e.g. viai.sentinel.download)g.region n=5944230 s=5603910 w=564260 e=823750 res=10 -pi.sentinel.import extent=region ...i.zero2null map=T31UCV_20210329T105631_B08_10mfix
The bug is introduced because
a) Setting the region to the input raster does not necessarily set it to the maximum no-null() extent. This is now ensured with
g.region zoom=...b) After setting the region to the input raster, there may be border areas which are already null(). These are now excluded from the result of
r.grow.distancetoo.