how to calculate overlapping rasters

813
2
09-26-2019 08:32 AM
GeorgiosKerametsidis
New Contributor

Hi,

There was a similar question 3 years ago, but still I have some difficulties executing a code in Raster Calculator. So, I have 2 rasters :
1. "Seal Density", with 5 classes: 0, 1, 2, 3, 4
2. "Fishing Intensity", with 10 classes: 0, 3, 6, 11, 19, 28, 38, 48, 59, 73

I arbitarily labelled the classes myself based on the ranges (provided by Kernel Density analysis). In order to identify overlapping pixels, I ran the code:

Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m" ==  0), 00, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m" == 3), 03, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m" == 6), 06, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 11), 011, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 19), 019, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 28), 028, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 38), 038, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 48), 048, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 59), 059, (Con(("KernelD_seal_all" == 0) & ("LineDen_Fish_ALL_100m"== 73), 073, Con(("KernelD_seal_all" == 1) & ("LineDen_Fish_ALL_100m" ==  3) ..... and so on with all combinations.

It's very lengthy and I don't get the 50 combinations (50 classes?) I expect, rather I only get a "zero" class.

Thank you in advance!

0 Kudos
2 Replies
SambhaviJoshi
New Contributor

If you are looking to do this using raster calculator, you can multiply one of your rasters with 100 and then add them. 
should look something like ("Seal Density" * 100) + "Fishing Intensity" .

Otherwise, if you are comfortable with python or R you can simply iterate with a for loop into all the values and regenerate your new raster with the concatenated values.

0 Kudos
curtvprice
MVP Esteemed Contributor

You could also use the Combine tool and add and calculate a new field in the resulting raster attribute table. The output of Combine gives you every unique combination of inputs.

 

Raster outputs can only be numbers, but fields can be text. So if you Combine integer grids X1 and X2 you'll have Long fields X1 and X2 in the output table.  You could then add a text format field and calculate it with the Calculate Field tool (using Python syntax) with an expression like:

"{:0>3d}{:0>3d}".format(!X1!,!X2!)