English

How To: Merge grids with Avenue

Summary

The script in this article uses the Mosaic request to merge two or more grids into one grid theme. This code and data type require the Spatial Analysis extension.

Procedure

You must have a grid theme active before running the script. The output will be called Grid1 and will be written to the $HOME directory.

  1. Open a new script window.

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

  2. Copy the following code into the script window:

    Code:
    '-- Script: Grid_mosaic.ave

    v = av.getactivedoc
    gthemes = v.getthemes
    gthms = list.make

    for each t in gthemes
    if (t.is(gtheme)) then
    gthms.add(t)
    else
    continue
    end
    end

    if (v.getactivethemes.count < 1) then
    msgbox.info("Active theme must be a Grid theme","")
    exit
    end

    g1 = v.getactivethemes.get(0)
    if (g1.is(gtheme).not) then
    msgbox.info("Active theme must be a Grid theme","")
    exit
    end

    gthms2 = gthms-{g1}
    mrglist = msgbox.multilist(gthms2,
    "Pick grid(s) to mosaic with"++g1.getname,
    "Create Grid Mosaic")
    if (mrglist= nil) then exit end
    thegridlist = list.make

    for each gt in mrglist
    gr = gt.getgrid
    thegridlist.add(gr)
    end

    outgrid = g1.getgrid.mosaic(thegridlist)
    newtheme = gtheme.make(outgrid)
    v.addtheme(newtheme)
    v.invalidate

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