#5087 closed defect (fixed)
[PATCH] gdalwarp does not apply source nodata value to destination
Reported by: | etourigny | Owned by: | etourigny |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.0 |
Component: | Utilities | Version: | unspecified |
Severity: | normal | Keywords: | warp, nodata |
Cc: |
Description
I have just noticed that destination nodata value is not set when -dstnodata option is not used in gdalwarp.
This can be problematic when warping a dataset with no data values, as the result can be different from expected, if -dstnodata is not set. gdalwarp does use source nodata pixels if -srcnodata is not used.
I consider this as a bug (or at the very least a limitation), because one cannot warp a dataset in an automatic fashion and get expected output (with same nodata value as input).
Would it be OK to copy them over if -dstnodata is not used, or would there be problems with doing this? Or perhaps a new argument -copynodata could be added if there is fear of disruption.
Attaching a patch wich copies over nodata values if -dstnodata argument is not used, and if source nodata exists.
Attachments (3)
Change History (13)
by , 11 years ago
Attachment: | warp-nodata.txt added |
---|
follow-up: 2 comment:1 by , 11 years ago
follow-up: 3 comment:2 by , 11 years ago
Owner: | changed from | to
---|
Replying to rouault:
In case there's a use for not setting nodata to the target dataset, perhaps "-dstnodata none" could be recognized.
I think this happens already with srcnodata. Your suggestion is to copy nodata from source to destination, unless another value is given in dstnodata (use those values) or 'none' (do not set nodata).
Can I apply this to 1.10 also?
thanks
comment:3 by , 11 years ago
I think this happens already with srcnodata. Your suggestion is to copy nodata from source to destination, unless another value is given in dstnodata (use those values) or 'none' (do not set nodata).
Yes
Can I apply this to 1.10 also?
Changing behaviour seems a bit risky for a maintenance version.
by , 11 years ago
Attachment: | warp-nodata2.txt added |
---|
comment:4 by , 11 years ago
Milestone: | → 2.0 |
---|
Attached a new patch which explicitly does not set nodata when argument "none" is given. If there are less than #bands arguments, then the last value is used (if "none" remaining bands do not have a nodata value). I have not touched srcnodata. None of this is documented (including srcnodata=none), I will update.
Please review. Will not apply to 1.10, thanks!
comment:5 by , 11 years ago
Actually just noticed that None is mentioned in the docs, but the parsing should be fixed (tests for n*).
by , 11 years ago
Attachment: | warp-nodata3.txt added |
---|
comment:7 by , 11 years ago
The printf( "Copying nodata values from source %s to destination %s.\n" should be conditionalized by if (!bQuiet )
comment:8 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
ok thanks for your suggestions
applied in trunk (r26009)
comment:9 by , 10 years ago
Milestone: | 2.0 → 1.11.0 |
---|
In case there's a use for not setting nodata to the target dataset, perhaps "-dstnodata none" could be recognized.