0

I'm trying to run the following code in Arcpy in ArcMap 10.1 but keep getting an parsing error syntaxerror. I've used ArcGIS for years but am new to Arcpy.

>>> import arcpy
>>> from arcpy import env
>>> from arcpy.sa import *
>>> arcpy.env.workspace = r"S:\*PATH*.gdb"
>>> outDir = "S:\*PATH*.gdb\\"
>>> for fc in arcpy.ListFeatureClasses("*_150m"):
...     outfc = outDir + arcpy.Describe(fc).baseName + "_area"
...     arcpy.gp.TabulateArea_sa(fc,"siteID",Raster("NLCD_2011_landcover_raster_Chicago_proj"),"Value",outfc,“30”)
...     
Parsing error SyntaxError: invalid syntax (line 3)
  • 3
    Did you forget to specify a raw formatting option on the outDir declaration? Either way it's a fatal naming error with the "*PATH*" stuck in the question, masking the true problem. – Vince Nov 19 '16 at 17:07
  • I think this will be easier to debug if you use a Python IDE (e.g. IDLE) and run the same code as a script.i.e. no >>> or ... to make it easier for potential answerers to copy/paste for testing. – PolyGeo Nov 21 '16 at 22:48
0

I rarely work with Spatial Analyst but I think the issue will be with your third parameter which is for the in_class_data and expects a Raster Layer | Feature Layer to be supplied.

arcpy.gp.TabulateArea_sa(fc,"siteID",Raster("NLCD_2011_landcover_raster_Chicago_proj"),"Value",outfc,“30”)

You have used Raster("NLCD_2011_landcover_raster_Chicago_proj") which appears to be neither of those things. I suspect it should just be "NLCD_2011_landcover_raster_Chicago_proj".

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.