I am trying to combine 2 rasters: one with values = 1 and the other with values = 0 because I need a final raster with no empty cells. When I use the Raster calculator, the resulting raster only retains the cells with value = 1. It ignores cells with value=0 so therefore I now have a new raster with many No Data cells. How do I combine these 2 rasters and maintain both value = 1 and value =0, preferring value =1. Using ArcGIS 10.2.2
-
1What GIS software are you using the raster calculator from?– PolyGeo ♦Dec 14, 2015 at 4:28
-
try Raster Calculator with Con function but be sure that 0 isn't set to nodata and the spatial references match... A picture of what you're trying to achieve might help here.– Michael StimsonDec 14, 2015 at 5:12
1 Answer
Assuming the problem, is that the extent of your two rasters are not the same(mismatching nodata cells during overlay), and also that you are using ArcGIS:
Con(((IsNull(Raster0)) & (Raster1 ==1)), 1,Con(((IsNull(Raster1)) & (Raster0 ==0)),0,Con((Raster1 ==1) & (Raster0 ==0),1,-1)))
OR | difference below is that I used the rasters themselves as a true statement rather than the constant 1 and 0.
Con(((IsNull(Raster0)) & (Raster1 ==1)), Raster1,Con(((IsNull(Raster1)) & (Raster0 ==0)),Raster0,Con((Raster1 ==1) & (Raster0 ==0),Raster1,-1)))
You can then use setnull
to convert all areas that are marked -1 into nodata, but I doubt that there will be any combination left to be assigned as -1.