I am simply trying to extract the mean of each raster within a geodatabase and write the value to a table. I have done this successfully with another set of rasters, but now I keep getting the following error: Parsing error SyntaxError: invalid syntax (line 8). I am at a loss for what is causing this.

import arcpy
from arcpy import env
env.workspace = "G:/Research/Sand Dams/Datasets/Ukraine.gdb/"

rasters=arcpy.ListRasters("*", "All")

for inRaster in rasters:
    UkrMEANResult = arcpy.GetRasterProperties_management(inRaster, “MEAN”)
    UkrMean = UkrMEANResult.getOutput(0)
  • 3
    Check the double quotes around MEAN - it looks to me like they are not the standard ones - and the highlighting shows it too. – PolyGeo Jan 19 '16 at 3:52
  • Try removing the last forward slash from the string where you set the workspace environment? – Hornbydd Jan 19 '16 at 11:18

I'm adding an answer here for completeness, even though it seems that the question was answered in the comments.

As @PolyGeo noted, the quotes you have surrounding MEAN in the following line:

UkrMEANResult = arcpy.GetRasterProperties_management(inRaster, “MEAN”)

are referred to as curly quotation marks (also known as "smart quotes" or typographer's quotes). Some word processors, such as Microsoft Word, will sometimes automatically create these instead of straight quotes. This Office support page explains how to turn off the feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.