1

I am trying to write a python script to batch Aggregate a bunch of different rasters. I get a Parsing Error Syntax error for line 11.

# Batch Aggregate raster tool
import arcpy
from arcpy import env  
from arcpy.sa import *

env.workspace = r"C:\rasters"
out_workspace = r"C:\rasters\agg"

rasters = arcpy.ListRasters()

for raster in rasters
    outAggreg = Aggregate(raster, 10, "MEAN")
    outAggreg.save(out_workspace, raster + "_agg")
1
  • 1
    You are missing a colon after rasters.
    – Paul
    Jul 13, 2013 at 20:26

1 Answer 1

3

Try the following changes:

# Batch Aggregate raster tool
import arcpy, os
from arcpy import env  
from arcpy.sa import *

env.workspace = r"C:\rasters"
out_workspace = r"C:\rasters\agg"


rasters = arcpy.ListRasters()

for raster in rasters:
    outAggreg = Aggregate(raster, 10, "MEAN")
    outAggreg.save(os.path.join(out_workspace, raster + "_agg.tif"))
3
  • It ran, but this time I get an error: RuntimeError: ERROR 010093: Output raster format UNKNOWN is unsupported. The input raster is an ECW and aggregate can't output that - it can output TIFFs though.
    – detroit_hc
    Jul 13, 2013 at 20:40
  • 1
    Try adding the .tif extension to the output path.
    – Aaron
    Jul 13, 2013 at 20:51
  • 1
    Bingo. out_workspace, raster + "_agg.tif" Thanks for the help!
    – detroit_hc
    Jul 13, 2013 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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