I'm Just wondering how to incorporate a conditional statement basically to say: if value in raster >= 128, then put in new raster, otherwise make the values null.

Basically the purpose of this is that I only want to show rivers and waterbodies within the raster, and I don't know of any other way to do this.


You can use Set Null statement:

 OutRas = SetNull(InRas1 < 128, InRas1)

The above function will set all the values less that 128 to null.

The above code can be run using Raster Calculator. If you are using Python, your code should be adjusted to like this outSetNull = SetNull("inRaster", "inRaster", "VALUE < 128")

Try to avoid starting your variable name with number as Python doesn't accept starting variable names with numbers.

| improve this answer | |
  • Thanks for your quick response, I keep getting this error " ERROR 000989: python syntax error: parsing error syntaxerror: invalid syntax (line 1)" This is what I have put in 2012_statsum_out=SetNull("2012_statssum" < 128, "2012_statssum") – alyssa Apr 4 '16 at 8:42
  • I adjusted my answer for more information. – ahmadhanb Apr 4 '16 at 9:05
  • Thankyou very much about the advice regarding numbers, that was the issue in raster calculator. – alyssa Apr 4 '16 at 9:15

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.