kpzimmer

Syntax Error Calculating Cell Statistics

Discussion created by kpzimmer on Jun 12, 2010
Latest reply on Aug 27, 2010 by Dan_Patterson
Hello,

I am very new to python and am having trouble with the syntax for a script for calculating cell statistics for a series of rasters. I have set up objects to equal a specific raster and then I am attempting to get cell statistics for these rasters; however, there is a syntax error listing these objects in the execution statment for cell statistics:

For example the five rasters I want to run a mean cell statistic on are identified as such:
    rst1 = "Montana_Canada_NDVI_A" + Year + "D273.tif"
    rst2 = "Montana_Canada_NDVI_A" + Year + "D289.tif"
    rst3 = "Montana_Canada_NDVI_A" + Year + "D305.tif"
    rst4 = "Montana_Canada_NDVI_A" + Year + "D321.tif"
    rst5 = "Montana_Canada_NDVI_A" + Year + "D337.tif"

I've tried running cell statistics using the following syntax but get a syntax error:
gp.CellStatistics_sa(rst1;rst2;rst3;rst4;rst5, outRaster, "MEAN")

I've also tried adding quotation marks to the syntax (see below)
gp.CellStatistics_sa("rst1;rst2;rst3;rst4;rst5", outRaster, "MEAN")

but then I get an error that says:

Executing: CellStatistics rst1;rst2;rst3;rst4;rst5 H:\GEOG683\SeasonalNDVIs\Fall_2009 MEAN
Start Time: Sat Jun 12 21:52:54 2010
ERROR 010024: Error during conversion.
Failed to execute (CellStatistics).

Any help or advice would be greatly appreciated!

Full script is attached.

Thanks in advance.

Attachments

Outcomes