1

I am confused with the results of using a condition in gdal_calc. Initially I thought that gdal_calc was setting pixels to nodata where a condition is not met. In the documentation (http://www.gdal.org/gdal_calc.html) it is said that the following command sets values of zero and below to null.

gdal_calc.py -A input.tif --outfile=result.tif --calc="A*(A>0)" --NoDataValue=0

If I try this command:

gdal_calc.py -A input.tif --outfile=result.tif --calc="A*(A>0)" --NoDataValue=-9999

The pixels where the condition is not met are set to zero.

Should I understand that the term null used in the documentation actually refers to pixels with a value of zero?

asked Jul 17, 2018 at 10:04

1 Answer 1

4

You should understand the example so that

--calc="A*(A>0)" 

makes all pixels with value zero or below into zero, and after that

--NoDataValue=0

sets the metadata to tell that zero means nodata. With you modified command the zeroes are set as before but you are telling that pixels with value -9999 are nodata, thus zeroes are not nodata. I am not sure but I suppose that if input data had originally nodata set to something else than -9999 then both the metadata and those nodata pixels would be converted into -9999.

answered Jul 17, 2018 at 18:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.