Using Model Builder I need to reclassify slope rasters with percents range value. I have read and ask here batch reclassify rasters with different elevation ranges, but I still need more explanation.

Each one of my rasters has different ranges, this is an example from manual classify table:

**Image 1**
Old Values,New Values
0-278,1 (8%)
278-523,2 (15%)
532-871,3 (25%)
871-1394,4 (40%)
1394-3486,5 (100%)

**Image 2**
Old Values,New Values
0-471,1 (8%)
471-883,2 (15%)
883-1472,3 (25%)
1472-2355,4 (40%)
2355-5889,5 (100%)

I need to keep that 8%,15%,25%,40% & 100% ranges. I'am thinking to read each image ranges and write it to a table on the fly, but I don't know for sure how to do that.


I think I find a way to do it, just not sure how it is done.

1. I'll get the maximum value using Get Raster Properties tool
2. then do a mathematic calculations (maxValue "multiplied by" (8 "divided by" 100))
3. write the output to dbf file with a format Low,High,Val (fill in 0 as the first Low field)
4. iterate the mathematic calculation for the next percents range (15%,25%,40% and 100%)
5. Fill in the last result of the mathematic calculation in the Low field of an on going calculation (example below)
6. load the dbf file to the Reclassify by Table tools, DONE.

I still need help with mathematic calculation part, I don't know Python.

MaxValue = 100

Low, High, Val
0, 8, 1
8, 15, 2
15, 25, 3
25, 40, 4
40, 100, 5
  • What is the percentage based on? Count of pixels or percent of range covered? – Michael Stimson Oct 30 '14 at 3:35
  • count of pixels – Zery Oct 30 '14 at 3:52
  • That makes the mathematics a little more complicated. You can of course get the min,max,mean and standard deviation from the statistics but working out what 8% of pixel coverage is a little more complex... the python for writing a table and extracting the ranges is comparatively easy. – Michael Stimson Oct 30 '14 at 4:07
  • Just excatly what is the mean of numbers in raster statistics? minimum or maximum number of what? pixels? I usually did a reclass to achieve percents that I want by manual reclassisfy tool, click classify and click on the break values the % symbol, and change it to my desired class. That is what I want to automate using model builder. – Zery Oct 30 '14 at 4:43
  • I'm not sure how to mathematically determine a percentage of pixels based on their values. Raster statistics are explained resources.arcgis.com/en/help/main/10.2/index.html#//…, theoretically you should be able to work out your break values based on min, max, mean and standard deviation but it's been a long time since high school for me and I can't remember grade 10 statistical mathematics... – Michael Stimson Oct 30 '14 at 4:48

I found a way to solved it, is not a very best practice solution though. I did it in 3 separate ways.

  1. Using model builder I do a batch slope conversion
  2. Using python script I get raster properties (MAXIMUM) and do a mathematic calculation of it then write the result into a dbf file (you need this http://dbfpy.sourceforge.net/)
  3. Using model builder I do Reclass by Table with input parameter from slope raster dan dbf file from #2 steps.

If you need the script, once again it is not a good practice of scripting.

import arcpy
from arcpy import env
from dbfpy import dbf
from arcpy.sa import *

arcpy.env.workspace = "C:/folder"
rasterList = arcpy.ListRasters("*", "ALL")

for raster in rasterList:
    rastName = str(raster)
    print 'Currently processing rater:', rastName
    elevationmax_str = str(arcpy.GetRasterProperties_management(rastName, "MAXIMUM"))
    print 'Elevation (max):', elevationmax_str
    elevationmax = int(float(elevationmax_str))
    High1 = elevationmax * 0.08
    High2 = elevationmax * 0.15
    High3 = elevationmax * 0.25
    High4 = elevationmax * 0.40     

    dbname = rastName + ".dbf"
    db = dbf.Dbf(dbname, new=True)
        ("LOW", "N", 15, 4),
        ("HIGH", "N", 15, 4),
        ("VAL", "N", 4),
    print db

    for low, high, val in (
        rec = db.newRecord()
        rec["LOW"] = low
        rec["HIGH"] = high
        rec["VAL"] = val
    print 'DONE'
    print 'NEXT RASTER'     
print 'FINISHED'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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