1

I am looking to combine two single-band, 1-bit rasters of the same spatial extent based on their relationship to a polygon (mask). The image shows a polygon displayed with a cross-hatch and the two input rasters (Raster 1 & Raster 2) as well as the desired output raster (Raster 3). I need to keep the Raster 2 cells that are covered by the polygon mask otherwise keep the Raster 1 cells. This seems like it could be accomplished using Con or map algebra with a mask, although I have not been able to find a solution. How can I combine two input rasters based on their relationship to a polygon (or mask)?

enter image description here

1 Answer 1

1

First and foremost, it's important to understand that Spatial Analyst tools that use vector data always convert the vectors to rasters internally. For example, even though the Zone Data in the Zonal Statistics tool accepts feature classes, they are rasterized internally; this is why very small zones are excluded and overlapping polygons are problematic.

With that in mind, here's what I would do:

  • Convert your polygon mask to a raster using the Feature to Raster tool. Make sure to set the extent and snap raster environment variables to be the same as your "Input Raster 1" and "Input Raster 2" (see screenshot below). The output will have the value of the selected field in the polygon's extent and Null everywhere else.

Environment variables

  • Using Raster Calculator, use a combination of Con and IsNull to set your value using the expression Con(IsNull("Rasterized polygon"), "Raster 2", "Raster 1"). This is just like an IF statement in Excel, where the first argument is the boolean expression, the second argument is the value if the expression returns True, and the third argument is the value if the expression returns False.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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