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 - https://c.na9.visual.force.com/apex/ideaView?id=087E00000004nNqIAI

Monday, December 21, 2015

Geocode by Awesome

When was the last time someone sent you a long list of place names and asked you to make a map out of it?  If you are like me, the first thing that might go through your head might go like "Oh really. You couldn't have given me a lat/long??".  Geocoding in ArcGIS is a pain, because you need to have a complete geodatabase.  That might mean every river, stream, lake, street, lightpost, etc. in the USA! Type in each address into Google Maps?  No way. I'd like to get out of my office chair before the end of 2016.  BatchGeo?  Makes great maps, but you can't export the results.  Enter the Geocode by Awesome Table Add-In for Google Spreadsheets. Finally a solution that lives up to its name!

Friday, December 11, 2015

How to e-mail a shapefile

Most GIS professionals are familiar with e-mailing shapefiles.  We've been doing it for a while.  However, for folks just starting out or for those who use ArcMap the process of e-mailing a shapefile may be a little mystifying.  Nonetheless, sharing your data is one of the most valuable GIS skills.  Recently I answered this question for a colleague.

Here is what I wrote:

"It depends on the kind of information that she needs/wants.  If he/she wants both the geographic and attribute data then the best way is to take all of the files associated with the shapefile and put them in a zip file together.  At a minimum you'd need the .shp, .shx, .dbf, but often there is .proj, .shp.xml, .sbn, and even .cpg.  You'll need to use My Computer/Windows Explorer to view all of these files.  ArcGIS treats them as if they are one. The zip file keeps all files together.  It isn't a necessary step, but it is often easier than sending all of the files as individual attachments.

If she/he is just interested in the attribute data or doesn't have ArcGIS then there are two ways to go.

1.  In the attribute table select the rows by highlighting them on the left and then copy and paste into Excel.  Lately I've been finding this method to not work in 10.3, however.

2.  Open Excel.  Open the .dbf file.  Copy and paste all of the contents into a new Excel file without altering the original .dbf (or it can corrupt the shapefile).

Finally, don't forget to check the size.  Anything larger than about 27 Mb probably won't e-mail, although file size limits are specific to the e-mail service used."