Select to view content in your preferred language

Reclassify

815
1
10-14-2014 05:20 PM
AmyKlug
Frequent Contributor

This is just a small test of what I am trying to do but when I try and reclassify (code below) I get a value of 50 when this particular raster should have the value of 9 (for 2014)

This happens when I iterate through rasters in ModelBuilder UNLESS I reclassify 1 raster at a time, then I get the correct value of 9 and the field with 2014 remains in the attribute table (disappears when I get 50 as a value when using ModelBuilder and Python).

Year is stored as text and raster's were derived from polylines.


import arcpy, os, traceback
from arcpy import env
from arcpy.sa import *


try:
    arcpy.env.overwriteOutput = True
    env.workspace = "C:/Risk2014/Rasters2014"
    inras = "siu140030a"
    remap = RemapValue([["2014", 9],["2013", 8]])


    arcpy.CheckOutExtension("Spatial")


    outReclass1 = Reclassify(inras, "STI_YR", remap, "NODATA") # Field STI_YR = 2014 in this example
    outReclass1.save("C:/Risk2014/TestReclass/rsiu140030a")
    os.startfile("U:\Projects\Risk\RiskTables.mxd")
except:
    traceback.print_exc()



EDIT

I got this code to work but have not checked it when iterating, will let everyone know


import arcpy, os, traceback


try:
    arcpy.env.overwriteOutput = True
    inras = "C:\\Risk2014\\Rasters2014\\siu140030a"
    outras = "C:\\Risk2014\\TestReclass\\rsiu140030a"
    remap = "'2014' 9;'2013' 8"


    arcpy.CheckOutExtension("spatial")


    arcpy.gp.Reclassify_sa(inras, "STI_YR", remap, outras, "DATA")
    os.startfile("U:\Projects\Risk\RiskTables.mxd")
except:
    traceback.print_exc()

0 Kudos
1 Reply
DallasShearer
Deactivated User

Looks like the code that you posted shows the part that is working, which is one raster at a time. I suggest posting the code that is causing issue.

0 Kudos