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")
lambertj
3,1224 gold badges22 silver badges39 bronze badges
asked Jul 13, 2013 at 20:23
1
  • 1
    You are missing a colon after rasters. Commented 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"))
answered Jul 13, 2013 at 20:34
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. Commented Jul 13, 2013 at 20:40
  • 1
    Try adding the .tif extension to the output path. Commented Jul 13, 2013 at 20:51
  • 1
    Bingo. out_workspace, raster + "_agg.tif" Thanks for the help! Commented Jul 13, 2013 at 20:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.