Script for Con Isnull processing

Discussion created by MahoneyChad on Sep 11, 2012
I am tasked with processing satellite images (4000) and need to convert zero values to nodata. I figured that the con isnull function would be the best. I have worked on this script taking bits and pieces from various scripts I use and/or found online. I get this error "Cellsize or analysis window are not set"

If anyone could help that would be great. Below is the script I am working with in 9.3

# Import system modules
import sys, csv, time, calendar, datetime, string, os, arcgisscripting
# from datetime import date, timedelta

# Create the Geoprocessor object
gp = arcgisscripting.create()



# Load required toolboxes...
gp.AddToolbox("C:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")

#Set the input workspace
gp.workspace = "C://Users//GIS Specialist//Desktop//SUMD//By Hour//00_15"

#Set the output workspace
outworkspace = "C://Users//GIS Specialist//Desktop//SUMD//Processed By Hour//00_15"

#Get a list of the featureclasses in the input folder
rasters = gp.ListRasters()

#Reset the enumeration to make sure the first object is returned

    #Loop through the list of feature classes  
raster = rasters.Next()

while rasters:
    #expression for the reclass where nodata is reclassed to 0
    expression = "con(isnull(" + raster + "), 0, " + raster + ")"
    #name and location of the raster output 
    outputRaster = outworkspace + "/" + raster

    gp.SingleOutputMapAlgebra_sa(expression, outputRaster)
    raster = rasters.Next()