Save time with ArcGIS and Python

I usually try to avoid using ArcGIS. As I prefer to do geo-spatial analysis in R, using some great packages including sp, raster and rgdal.

But some recent analyses have required some tendonitis inducing* mouse clicking in ArcGIS. Only a simple task of converting rasters to float files. But none the less, thumb, forefinger and mind numbing after a while.

Here is a basic loop which, will convert all rasters in a folder (inFolder) to floats in a output folder (outFolder). You could potentially use this for many different functions in arcpy.

# Import system modules
import arcpy
from arcpy import env

# Set local variables
inFolder = "T:\\Your_Directory\\Environmental Data\\Bioclim_ascii\\Rasters"
outFolder = "T:\\Your_Directory\\Environmental Data\\Bioclim_ascii\\Float"
arcpy.env.workspace = InFolder

for Ras in arcpy.ListRasters():
    arcpy.RasterToFloat_conversion(inFolder + "\\" + Ras, outFolder + "\\" + Ras + ".flt")

* no tendonitis was developed during this demo.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s