English

How To: Convert grid colormap file ( .clr ) into an ArcView scheme

Summary

Since ArcView Spatial Analyst does not apply colormap files (.clr) to grid themes, you can use the following script to create a new legend classification scheme based on a colormap file. The new scheme will be available in the grid theme's legend editor.

Procedure

  1. Make a backup copy of ..\esri\av_gis30\arcview\etc\nc_ramps.odb file.

    Note:
    This script modifies the nc_ramps.odb file. You can reset the legend schemes by replacing the new file with the original.

  2. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  3. Paste the following code into the new script window.

    Code:
    '-- This script will read a grid colormap (.clr) file and
    '-- create a new scheme out of it. After restarting ArcView,
    '-- the new scheme can be applied to the grid in the legend editor.
    '
    ' Warning: This script will modify the default color schemes for ArcView.
    ' Make a backup copy of $AVHOME/etc/nc_ramps.odb before running
    ' this script.

    NewScheme = SymbolList.Make

    rgb_name = FileDialog.Show("*.clr", "Grid .clr files", ".clr to Scheme")
    if (rgb_name = nil) then exit end

    rgb_file = LineFile.Make(rgb_name, #FILE_PERM_READ)
    num_syms = rgb_file.GetSize
    for each s in 1..num_Syms
    buf = rgb_file.ReadElt
    if (buf = nil) then
    continue
    elseif(buf.contains("#")) then
    continue
    elseif(buf = "") then
    continue
    else
    if(buf.contains(",")) then
    atoken = ","
    else
    atoken = " "
    end
    tokens = buf.AsTokens(atoken)
    r = tokens.Get(1).AsNumber
    g = tokens.Get(2).AsNumber
    b = tokens.Get(3).AsNumber
    nc = Color.Make
    nc.SetRGBList({r,g,b})
    NewScheme.Add(nc)
    end
    end
    rgb_file.close

    NewSchemeName = Msgbox.Input("Enter a Name for your new Scheme:",
    "Add a Scheme","New Name")
    NewScheme.SetName(NewSchemeName)
    Schemes = ODB.Open("$AVHOME/etc/nc_ramps.odb".AsFileName)
    Schemes.Add(NewScheme)
    Schemes.Commit

    msgbox.info("Please restart ArcView for this new scheme to be" +
    " recognized.","Restart ArcView")

  4. Click the
    [O-Image] Script compile button
    button to compile the script.
  5. Click the
    [O-Image] Run compiled script button
    button to run the script.