marita85

Integer in python 2.6.5 with ArcGIS 10

Discussion created by marita85 on Jun 20, 2011
Latest reply on Jun 21, 2011 by marita85
I've just started to work with python in ArcGIS 10.
I'm trying to make a simple program to transform a raster in float format to Integer, I only replaced my variables in the example help and it doesn't work. Here I put my code if anyone can help me.

import arcpy
import sys
import string
import os
from arcpy import env
from arcpy.sa import *

env.workspace = "D:/floats"
desc="_14p"
# Define the files and number of files to process
for root,files,dir in os.walk("D:/floats"): 
    #print dir
    num=len(dir)
    print "number of files: ", num

try:
    for n in range(0,num):
        inRaster = dir[n]
        ext='.flt'
        outInt = inRaster[:-len(ext)]+str(desc)
        arcpy.CheckOutExtension("Spatial")
        outInt=Int(inRaster)
        outInt.save(outint)
        print n

except:
    #print error message if an error occurs
        print arcpy.GetMessages()

Outcomes