Zonal Statistics as Table in ArcPy

Forgive my detour back to the “dark side”: this is yet again something I needed to get done quickly, so I did it the way I already know. For this example in Python, you’ll need…

import arcpy
from arcpy import env
from arcpy.sa import *
import os

A few reminders when scripting…

  • make sure your projections match
  • your work space environment should be something you own/have permissions for

Remember, you can set and reset the work space, so do that as needed. The intermediate results will need to be written somewhere, so make sure the work space for the calculations is a folder where you have read/write access. From there, the syntax is pretty straightforward:

ZonalStatisticsAsTable (in_zone_data, zone_field, in_value_raster, out_table)

Leave a Reply

Your email address will not be published. Required fields are marked *