Only extract values that are the same in two raster dataset

4345
12
Jump to solution
06-11-2015 05:47 AM
DitlevReventlow
Occasional Contributor II

Hey everyone.

I have two raster datasets with the same spatial resolution and extent. Both these datasets have values between 0 to 16.

How do I extract only the values that are the same in both datasets?

Thank you!

Best regards

Ditlev Reventlow

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Ditlev,

You could use the Minus tool to subtract the two rasters.  Then, perform an Extract Values by Attributes for values that equal 0.  These represent the cells that have the same value.

View solution in original post

12 Replies
DitlevReventlow
Occasional Contributor II

I mean where the cells in the two datasets have the same values.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi Ditlev,

You could use the Minus tool to subtract the two rasters.  Then, perform an Extract Values by Attributes for values that equal 0.  These represent the cells that have the same value.

DitlevReventlow
Occasional Contributor II

Great Thanks, do you think that my approach with raster calculators works as well?

0 Kudos
curtvprice
MVP Esteemed Contributor

There's also the Diff tool.

0 Kudos
DitlevReventlow
Occasional Contributor II

I think I might have gotten it to work now, but I am not completely sure.

I have written the following in raster calculator:

Con("bsh_lu_2012_e" == "bsh_lu_2001_e","bsh_lu_2012_e")

Does this look right?

I guess it is the same if I write:

Con("bsh_lu_2012_e" == "bsh_lu_2001_e","bsh_lu_2001_e")

Am I right about this conclusion?

DanPatterson_Retired
MVP Emeritus

Although they are identical, I think what you mean, is if the order of the rasters was switched in the equality check, the values would remain the same where the values are equal in the different time periods, but they would assume a different value where they are not equal.  So the question remains, what do you want to happen when the values are NOT equal

  • this == that   then keep this OR that...doesn't matter
  • this != that    then keep ???? or do something else
  • this == that, keep this, otherwise give it 0

Don't get hung up on the contents, focus on the logic

0 Kudos
DitlevReventlow
Occasional Contributor II

Dan,

I meant what is written,

Con("bsh_lu_2012_e" == "bsh_lu_2001_e","bsh_lu_2012_e")

or

Con("bsh_lu_2012_e" == "bsh_lu_2001_e","bsh_lu_2001_e")

But I am also intested in what happens if you turn around the rasters in the equality check. I just tried to play around in raster calculator. As far as i could see all these 4 statements:

Con("bsh_lu_2012_e" == "bsh_lu_2001_e","bsh_lu_2012_e")

Con("bsh_lu_2012_e" == "bsh_lu_2001_e","bsh_lu_2001_e")

Con("bsh_lu_2001_e" == "bsh_lu_2012_e","bsh_lu_2012_e")

Con("bsh_lu_2001_e" == "bsh_lu_2012_e","bsh_lu_2001_e")

all yeld the same output raster.

I want the output raster to have no value where the two rasters differ. This is the case for all the 4 statements above as far as I can see(when I right click and select "identify" on a cell that doesn't have the same value, there is simply nothing stated) .

I am not completely sure what you mean in the three examples you have given.

JakeSkinner
Esri Esteemed Contributor

Yes, your Con statement appears to be correct.

DanPatterson_Retired
MVP Emeritus

Con("bsh_lu_2001_e" == "bsh_lu_2012_e","bsh_lu_2001_e")

just leave the result the same if it isn't true

Con("bsh_lu_2001_e" == "bsh_lu_2012_e", "bsh_lu_2001_e", 0)

Con("bsh_lu_2012_e" == "bsh_lu_2001_e", "bsh_lu_2001_e", 0)

will set the value to " 0 " IF they aren't equal

Con statement help

Con statement how it works

That is what I was trying to get you to think about .... what to do if they weren't equal ...

0 Kudos