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.

Wednesday, January 20, 2016

Most popular downloads of 2015

Every year I tally up my papers, talks, posters, etc. for my annual evaluation. Last year I began to start tallying downloads for tools that I post online.  If my estimates are correct, I had 5,695 downloads in 2015 covering covering 26 tools/scripts. The most popular of my tools in 2015 were 1) polygon to centerline, 2) Climatic Water Deficit Toolbox, 3) Topography Toolbox (includes the Riparian Topography Toolbox and PRISM Data Helper), and 4) Landsat Toolbox with 2,034, 629, 629, and 511 downloads respectively. Hopefully, 2016 will provide opportunities for new tools and upgrades to existing ones in order to help solve research problems. All of the tools can be downloaded from HERE.

Monday, January 11, 2016

ArcGIS Idea - geoprocessing tool to create new network dataset

This one doesn't seem like rocket science to me.  It should be possible to create a new network dataset in ArcGIS in a model or with Arcpy -