Tuesday, March 3, 2015

Common question - How to combine raster and vector data and deal with NoData

This one is probably the most common question I get.  It goes something along the line of  "I've got some polygon/line data that I want to combine with a raster layer, but how do I deal with the NoData outside the polygon?". Other situations that this apply to include other raster outputs that use NoData as their background, such as outputs from Brownian Bridges, or remote sensing images in which part of the image may be masked. Hence, nearly everyone who works with ArcMap in a natural resource context is likely to encounter this problem at least once (if not nearly daily in my case).

Here is a hypothetical example and solution. In the picture to the right we've got a habitat model (raster) and buffered roads which are not suitable habitat for our hypothetical species. We wish to combine the two layers to yield a habitat model in which all areas near roads are not suitable habitat (value = 0).

In ArcGIS the first step would be to convert the polygon to raster. We might do this using the Polygon to Raster Tool.  It doesn't matter what the Value Field is set to but you probably want to set the Cellsize to the same as the habitat model layer (see the picture to the right).

Then use the IsNull tool  to convert all areas that are NoData to 1.  The IsNull tool is in the Spatial Analyst toolbox and is also available as Map Algebra in the Raster Calculator tool. IsNull is a really simple, but also one of the most powerful tools in ArcMap.

The final step involves the use of the Con tool in Spatial Analyst to combine the IsNull output with the original raster (see below). The input conditional raster should be the output from the IsNull tool. The expression selects all cells with a value of 0 (i.e. in this case they are within the road buffer). The true value is set to 0 to indicate that areas near roads are unsuitable habitat. The false value uses the original habitat suitability raster to indicate that for area not near roads the habitat is the same as the habitat model.

The final result  is map that looks like the one below. Areas near roads all have a value set to zero. You can also combine IsNull and Con in raster calculator using the following type of statement: Con(IsNull[Raster],0,[Raster]) or use ModelBuilder to streamline the process.


No comments:

Post a Comment