Adding two conditional statement for raster value replacing using ArcPy?

785
2
Jump to solution
10-01-2016 02:04 AM
ShouvikJha
Occasional Contributor III

I am trying to add two conditional function (whatever value of raster fall between 0 and 1 range remain same other value replace by 0), so far i have i can put single condition only but i am trying to execute two function. . Below is my conditional statement script line.

outRaster = Con(localRaster <0.0, 0, localRaster)

Above code only can replace whatever raster value below 0 will replace by 0, but how to add this condition > 0.0 and < 1 remain same and other value replace by 0.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor
outRaster = Con(localRaster > 0.0, Con(localRaster < 1, localRaster, 0), 0)

if the localraster is > 0, then do a check to see if it is < 1.  If it is <1, it will be >= 0 and < 1... sooo keep the value

If not... assign it 0, in both cases

View solution in original post

2 Replies
DanPatterson_Retired
MVP Esteemed Contributor
outRaster = Con(localRaster > 0.0, Con(localRaster < 1, localRaster, 0), 0)

if the localraster is > 0, then do a check to see if it is < 1.  If it is <1, it will be >= 0 and < 1... sooo keep the value

If not... assign it 0, in both cases

ShouvikJha
Occasional Contributor III

Dan Patterson‌. Thank you. Now Perfectly  its working.