PROBLEM
A floating point grid does not display or label properly in ArcView Spatial Analyst.
The range of values of the grid is much smaller than the range of values set in the legend.
Code:
'-- Get the original grid legend and write parameters to a temporary table
theview = av.getactivedoc
thetheme = theview.getactivethemes.get(0)
theleg = thetheme.getlegend
thenum = theleg.getnumclasses - 1
thevtab = vtab.makenew("c:\temp\class2.dbf".asfilename, dbase)
thevtab.seteditable(true)
therecfld = field.make("Recno", #FIELD_DECIMAL, 6,0)
thelfld = field.make("Label", #FIELD_CHAR, 30, 0)
therfld = field.make("Range", #FIELD_CHAR, 30, 0)
theminfld = field.make("Min", #FIELD_DECIMAL, 15, 5)
themaxfld = field.make("Max", #FIELD_DECIMAL, 15, 5)
thevtab.addfields({therecfld, thelfld, therfld, theminfld, themaxfld})
for each i in 0..thenum
therec = thevtab.addrecord
theleglist = theleg.returnclassinfo(i)
thelabel = theleglist.get(0).clone
therange = theleglist.get(1).clone
themin = theleglist.get(3).clone
themax = theleglist.get(4).clone
thevtab.setvalue(therecfld, therec, (i + 1))
thevtab.setvalue(thelfld, therec, thelabel)
thevtab.setvalue(therfld, therec, therange)
thevtab.setvalue(theminfld, therec, themin)
thevtab.setvalue(themaxfld, therec, themax)
theleglist.empty
end
thevtab.seteditable(false)
theleg.save("c:\temp\one.avl".asfilename)
'-- Reclass grid using the temporary table
g = thetheme.getgrid.reclass(thevtab, theminfld, themaxfld, therecfld, true)
'-- Join attributes in temp table to reclass grid
thegvtab = g.getvtab
thevalfld = thegvtab.findfield("value")
thegvtab.join(thevalfld, thevtab, therecfld)
g2 = g
'-- Make new legend and assign values, symbols and labels
thenewleg = legend.make(#SYMBOL_FILL)
thenewleg.load("c:\temp\one.avl".asfilename, #LEGEND_LOADTYPE_ALL)
thegtheme = gtheme.make(g2)
for each j in 0..thenum
'thel = theg2vtab.returnvalue(thelabelfld, j)
the2leglist = thenewleg.returnclassinfo(j)
jj = j + 1
the2leglist.set(1, jj.asstring)
the2leglist.set(3, jj)
the2leglist.set(4, jj)
thenewleg.setclassinfo(j, the2leglist)
end
'-- Set legend and add grid to view
thegtheme.setlegend(thenewleg)
theview.addtheme(thegtheme)
Article ID:000003535
Get help from ArcGIS experts
Download the Esri Support App