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
Solved! Go to Solution.
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.
I mean where the cells in the two datasets have the same values.
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.
Great Thanks, do you think that my approach with raster calculators works as well?
There's also the Diff tool.
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?
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
Don't get hung up on the contents, focus on the logic
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.
Yes, your Con statement appears to be correct.
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
That is what I was trying to get you to think about .... what to do if they weren't equal ...