1

I have a question regarding the Con statement when used in the SA Raster Calculator.

I am reclassifying a raster (categorical, integer) based on my own mappings but also on another raster (for some of the classes). So example I have

Con("pft.tif"==0,17,
Con("pft.tif"==1,1,
Con("pft.tif"==2,Con("aez.tif"==1,6,5),
Con("pft.tif"==3,3,
Con("pft.tif"==4,4,255)))))

I've written it like that for ease of reading.

My issue arises when there's no value for aez.tif (i.e. aez.tif value is NoData or the raster does not extend to the pft.tif extent). From what I've seen the result is NoData. I thought it would result in "5". What I want is that if the Con with aez.tif results in this no value, that it does infact return some default that I've specified. I can't do that with e.g.

Con("pft.tif"==2,Con("aez.tif"==1,4,5),5)

since that terminates the Con while I still have other conditionals to try.

1

One way out would be to extend the extents of aez.tif to match pft.tif and put some bogus value on the NoData (-9999 for instance).

Another option is to use the isNull function (or a not isNull) inside your Con statement so the null value is considered.

Another thing that might help is to check the processing extent of your raster calculator. By default it uses the intersection of inputs (ptf and aez) but I believe you can force it to consider the extent of one or another.

  • Great thanks. I went for your first suggestion by creating another raster with nodata=2. However your second suggestion seems more efficient (i.e. I don't have to create another raster). – tanksnr Dec 3 '15 at 8:14
  • Glad to hear the answer was useful and it worked – Daniel Dec 4 '15 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.