1

I have two binary rasters showing habitat suitability (0 = unsuitable, 1 = suitable) under current and future climate scenarios. I am trying to create a raster showing:

0 = cells that are not suitable under either scenario (i.e. = 0 in both rasters) 1 = cells suitable under current (=1) but NOT future (=0) 2 = cells suitable under both scenarios (i.e. both = 1) 3 = cells suitable under future (=1) but not current (=0)

So the final raster will consist of values of 0 , 1 , 2, 3, 4 (and no data = -9999)

I am struggling with the correct syntax in raster calculator. Is it possible to do this all in one line of syntax or do I have to create four separate rasters?

To summarise my files:

I have a current binary raster (Model10a_bin.tif) and a future binary raster (Model10a_yr2050_bin.tif) and I am trying to create a new raster showing the following:

If Model10a_bin.tif = 0 and Model10a_yr2050_bin.tif = 0 ; Value new raster = 0

If Model10a_bin.tif = 1 and Model10a_yr2050_bin.tif = 0 ; Value new raster = 1

If Model10a_bin.tif = 1 and Model10a_yr2050_bin.tif = 1 ; Value new raster = 2

If Model10a_bin.tif = 0 and Model10a_yr2050_bin.tif = 1 ; Value new raster = 3

  • 1
    I guess you forgot to mention what software you're talking about (add a tag too). – Germán Carrillo Jan 21 '15 at 17:09
  • 1
    I don't see how you will ever get a value of 4. If you are willing to change your coding a little you can obtain the result easily by adding twice the future raster to the current raster: this would swap the meanings of "2" and "3". If you need these codings, the same approach will work after complementing the future raster (by applying "not" or subtracting it from 1). But as far as syntax goes, you will need to tell us more about what GIS platform you are using, right down to the exact version and how you invoke its raster calculator. – whuber Jan 21 '15 at 18:16
  • Sorry - yes ArcMap / Catalog 10.2 on Windows 8.1 – LouisP Jan 21 '15 at 21:16
3

Assuming ArcGIS use combine, e.g.

Combine (["a.tif","b.tif"])

Combines multiple rasters so that a unique output value is assigned to each unique combination of input values

  • Thank you very much, this is exactly what I needed and a very useful tool – LouisP Jan 23 '15 at 16:09
1

You could reclass one of the rasters so that your binary values are:

|Raster                  |Yes Value  |No Value   |
+------------------------+-----------+-----------+
|Model10a_bin.tif        |1          |0          |
+------------------------+-----------+-----------+
|Model10a_yr2050_bin.tif |2          |0          |

Then simply add the two together so the outputs of the new raster would be:

|Output            |Value  |
+------------------+-------+
|No + No (0, 0)    |0      |
+------------------+-------+
|Yes + No (1, 0)   |1      |
+------------------+-------+
|No + Yes (0, 2)   |2      |
+------------------+-------+
|Yes + Yes (1, 2)  |3      |

Slightly different than your breakdown, but similar results.

  • Yes, thank you, eventually worked out that reclassifying is the easiest way forward, just with slightly different class values, followed by adding the two together. – LouisP Jan 21 '15 at 21:16
0

with the raster calculator, you can use conditions to get exactly what you need :

Con("Model10a_bin.tif" == 0, Con("Model10a_yr2050_bin.tif" == 0, 0, 3), Con("Model10a_yr2050_bin.tif" == 0, 1, 2))

another single line algebra, shorter to write, is the sum of the first with the double of the second. But 2 and 3 are then inverted

"Model10a_bin.tif" + 2*"Model10a_yr2050_bin.tif"
  • Thank you very much - this is exactly what I was trying to do but can be easily achieved using "combine" as suggested below. Thanks for your help everyone – LouisP Jan 23 '15 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.