Sunday, January 31, 2016

Map algebra formula for calculating proportion of cover at different scales

Calculating the proportion of cover of different categorical classes (lets use a classified vegetation map as an example) isn't rocket science, however there are more steps involved that one might expect. Converting a categorical map to cover classes has a couple of advantages. One advantage is that it converts a categorical variable into a continuous variable making some models easier to develop and easier to interpret. Another advantage is that it allows the variable to be calculating at multiple spatial scales. When it comes to species distributions we usually don't expect the value of a single cell to be the primary driver of habitat selection. Rather it is the amount of different habitat types in some (usually unknown) neighborhood size that we expect to control habitat selection.

I've already reported on a tool for scaling up from categorical classes to continuous proportions of cover HERE.

In this post I provide a simple map algebra statement that can used in the raster calculator in ArcGIS to convert a single category in a categorical map to a percent cover map at some spatial scale.  This formula will do the trick:

(Float((FocalStatistics((Con("phase.tif" == 1, 1, 0)),NbrRectangle(33,33),"SUM")))) / (Float((FocalStatistics((Con("phase.tif" == 1, 1, 1)),NbrRectangle(33,33),"SUM"))))

All you need to do is swap out "phase.tif" with your raster, change the value after the == sign to represent the class that you are interested in, and change NbrRectangle(33,33) to a neighborhood size and shape of your choice.

If you have no gaps or holes in your raster dataset you are done.  However in many cases we are likely to have areas of NoData beyond which our raster will also be NoData.  To rectify this situation we can apply a second map algebra statement:

Con((IsNull("prpn.tif") == 1), 0, "prpn.tif")

Just swap out "prpn.tif" with the name of the raster resulting from the above step.  The IsNull tool ensures that NoData areas are identified and the conditional statement sets those areas to 0.

In the image below on the left the vegetation class in black is converted into a proportion cover with darker blues indicating higher values. The light blue indicates that either 1) a different vegetation class was dominant or 2) none of the vegetation classes were present in the spatial neighborhood.

No comments:

Post a Comment