Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Trying to write a python script to batch Aggregate a bunch of different rasters. 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")
share|improve this question
1  
You are missing a colon after rasters. –  Paul Jul 13 '13 at 20:26

1 Answer 1

up vote 3 down vote accepted

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"))
share|improve this answer
    
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 '13 at 20:40
1  
Try adding the .tif extension to the output path. –  Aaron Jul 13 '13 at 20:51
1  
Bingo. out_workspace, raster + "_agg.tif" Thanks for the help! –  detroit_hc Jul 13 '13 at 20:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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