How to re-classify certain raster values based on another raster (land use classification)?

1533
1
Jump to solution
03-29-2020 06:52 AM
SabineHain
New Contributor

Hello everyone,

I am quite new to ArcGIS so this may be simple, but I just cannot find the right answer to this. 

I have two rasters (.tif) that I have derived from Sentinel images. One is a raster with land use classification derived from training sample data and Supervised Classification at 10 m resolution. It has 5 classes (buil-up/bare, forests, mining pits, croplands/grasslands, and cloud cover). I have also computed the MNDWI for each raster cell based on green and SWIR bands at 20 m resolution. 

I have noticed that in the LU raster, it has wrongly classified water bodies as either cropland or forest. I want to correct this by assigning values in the LU layer that are cropland or forest as water bodies where the MNDWI is higher than 0.4. I have tried overlays, selection by attributes, and the raster calculator in various forms, but I keep getting error messages. The conditionals I use in the raster editor (e.g. something like: water = ("LU.tif" == "cropland") & ("mndwi.tif" >= 0.4) do not compile. I feel like I am missing something very obvious. 

I was able to extract the water bodies using watbod = "mndwi.tif" >= 0.4, but now I cannot use it to extract the relevant cells in the cropland/forest LU layer - I can often compile, but then get a layer with results spanning 0 to 0. 

Is this because of the differing resolutions? Where am I failing here?

One additional note: I often also encounter the error notice: "The truth value of a raster is ambiguous. Invalid use of raster with Boolean operator or function." In this case, I had tried variations of watbod_new = "LU.tif" == "cropland" & "watbod" == 1, with watbod = 1 being the extracted waterbodies. Adding parentheses resulted in a raster with the value being 0 everywhere. 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

The land use tiff should be classified by coded values, e.g 1 = cropland, 2 = forest and therefore not interrogable by a text query such as 'if LU.tif == 'forest'... then..)

I think it should be pretty easy in raster calculator with a Con statement:

Con(InRas1 condition and InRas2 condition, True, False)

my syntax might be a bit off, ive not tested it, if not try if "LU.tif" in (1,2) instead.

Con( ("LU.tif" == 1 or "LU.tif" == 2 and "mndwi.tif" >= 0.4), "mndwi.tif", "LU.tif") 

my syntax might be a bit off, ive not tested it, if not try if "LU.tif" in (1,2) instead.

View solution in original post

1 Reply
DavidPike
MVP Frequent Contributor

The land use tiff should be classified by coded values, e.g 1 = cropland, 2 = forest and therefore not interrogable by a text query such as 'if LU.tif == 'forest'... then..)

I think it should be pretty easy in raster calculator with a Con statement:

Con(InRas1 condition and InRas2 condition, True, False)

my syntax might be a bit off, ive not tested it, if not try if "LU.tif" in (1,2) instead.

Con( ("LU.tif" == 1 or "LU.tif" == 2 and "mndwi.tif" >= 0.4), "mndwi.tif", "LU.tif") 

my syntax might be a bit off, ive not tested it, if not try if "LU.tif" in (1,2) instead.