Error Accessing Env.Mask in Python

07-25-2013 09:02 AM
Occasional Contributor
Below is a snippet of code that I have been working on that loops through the geometry of multiple features of a shapefile and uses that geometry as a mask to get raster properties. However, I'm stumped as to why I continue to get the following error,

RuntimeError: Object: Error in accessing environment <mask>

import arcpy, os, string, csv
from arcpy import env

winsum = "D:/WERC/GIS_Layers/Summer-Winter Ranges/AllShps/WinterSummer.shp"
env.workspace = workspace
with arcpy.da.SearchCursor(winsum, ['SHAPE@', 'Name', 'Season']) as cursor:
    for row in cursor:
        name = row[1]
        season = row[2]
        env.mask = row[0]
        for raster in arcpy.ListRasters():
            stdResult = arcpy.GetRasterProperties_management(raster, "STD")
            print stdResult
            meanResult = arcpy.GetRasterProperties_management(raster, "MEAN")
            print meanResult
            minResult = arcpy.GetRasterProperties_management(raster, "MINIMUM")
            print minResult
            maxResult = arcpy.GetRasterProperties_management(raster, "MAXIMUM")
            print maxResult

If anyone could point me in the right direction it would be much appreciated. Thanks!
0 Kudos
1 Reply
Occasional Contributor
This morning I realized my issue and thought I would post the solution in case someone else has the same problem. I spaced it out that instead of env.mask = row[0] it has to be env.mask = 'SHAPE@'.
0 Kudos