# Finding the overlap between two rasters based on pixel values

I'm trying to find the intersection of two rasters. Raster A has the probability of a fish existing in each pixel and Raster B has the probability of a different fish existing in the same space. I need to find out where both rasters are showing a probability of 50% or greater, 60% or greater, etc in the same area. I can see that the probability of 50% for each raster overlaps, but I need to quantify the area.

I don't work with raster often. I tried converting to vector (polygons) and using the intersect tool, but the resulting polygons were very funky looking and did not represent the total area of overlap.

I'm using ArcGIS 10.6.

• Welcome to GIS SE. As a new user, please be sure to take the short tour to learn about the site's focused Q&A format. Please also edit your question to include details about what software and version you are using.
– Andy
Jan 6 '20 at 15:00

I am not sure if you are using python, or GUI and which one. I can provide you a solution with arcpy or ArcMap

It might be as simple as classification of rasters for the values. You can convert it to 0/1 raster and add both raster (or multiply them).

Solution here:

``````import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')

rasterA = r'path_to_raster'
rasterB = r'path_to_raster'

con_rasterA = Con(rasterA >= 0.5, 1, 0) #if raster > 50%, convert it to 1 else 0.
con_rasterB = Con(rasterA >= 0.5, 1, 0) #if raster > 50%, convert it to 1 else 0.
## where value is 2, it means match, else no match
result_multiply = con_rasterA * con_rasterB
## where value is 1, it is match, else 0

results.save(r'path_to_output')
``````

After that, just simply get all pixels with non-0 or 2 value (depend on method). For example with `Build Raster Attribtue Table`

In QGIS you can use Raster Calculator where in expression, you can do something like:

``````("RasterB2@1" > 0.5) * 1 + ("RasteA@1" > 0.5) * 1
``````

Save the output and it should be the same.

Bonus: Converting to polygon would also work. But! You must not generalize the dataset. In Arcgis (https://pro.arcgis.com/en/pro-app/tool-reference/conversion/raster-to-polygon.htm):

``````simplify must be False
``````

This should not be an issue in QGIS (GDAL) which converts it as real pixel.

Edit: Since you are using ArcGIS, it can be done with built in raster calculator (with Spatial Analyst extension). Put there:

``````Con("RasterA.tif">0.5,1,0) + Con("RasterB.tif">0.5,1,0)
``````

And as output whatever you want.

• I'm sorry I didn't mention it, but I'm using ArcGIS 10.6.
– Katy
Jan 6 '20 at 23:00
• @Katy no problem, if the answer helped you solved your problem, please accept it as solution:) Jan 7 '20 at 14:10