The following scripts were written in Avenue, the scripting language of ArcView version 2 (Environmental Systems Research Institute, Redlands, CA). To install these pattern finding applications, copy these five scripts into your project and create two new buttons in the View button bar called `Find Same' and `Blind Pattern.' Select `View.FindSame.ave' as the script for the `Find Same' button and `View.FindSameUpdate.ave' as the update script for the button. Select `View.BlindPattern.ave' as the script for the `Blind Pattern' button. These names may be shortened for a DOS-based operating system.'********************************************************************
'View.BlindPattern.ave
'Raj Singh, 1996
theView = av.GetActiveDoc
theThemeList = theView.GetThemes
dontstop = true
usedThemeList = List.Make
while (dontstop = true)
'Have the user choose a theme
themeChoice = MsgBox.Choice (theThemeList,"Select a theme of interest","Theme Select (Cancel when done)")
usedThemeList = usedThemeList.Add(themeChoice)
'if the user hits cancel, then they are done and we send
'the list of used themes to the calling script
if (themeChoice = nil) then
dontstop = false
returnVal = av.Run ("FS.IntersectThemes",usedThemeList)
exit
end
'Have the user choose a field from the chosen theme
themeChoiceFTab = themeChoice.GetFTab
themeChoiceFieldList = themeChoiceFTab.GetFields
themeChoiceName = themeChoice.GetName
titleName = themeChoiceName+" Attribute Selection"
fieldChoice = MsgBox.Choice (themeChoiceFieldList, "Select a field of interest",titleName)
if (fieldChoice = nil) then
MsgBox.Error("No field chosen","")
exit
end
'get summary info, so far mean, maximum, minimum
fieldsum = 0
fieldmin = 0
fieldmax = 0
for each recno in themeChoiceFTab
fieldVal = themeChoiceFTab.ReturnValue(fieldChoice,recno)
if ( fieldVal >= 0 ) then
fieldsum = fieldsum + fieldVal
end
if ( fieldVal < fieldmin ) then
fieldmin = fieldVal
end
if ( fieldVal > fieldmax ) then
fieldmax = fieldVal
end
end
numrecs = themeChoiceFTab.GetNumRecords
fieldmean = fieldsum / numrecs
statString = "MAX="+fieldmax.AsString+" MEAN="+fieldmean.AsString+" MIN="+fieldmin.AsString
'shows the user min & max and asks for user min & max
minString = fieldChoice.GetAlias+" statistics: "+statString+"."+"What is the MINIMUM value you are interested in?"
maxString = fieldChoice.GetAlias+" statistics: "+statString+"."+"What is the MAXIMUM value you are interested in?"
minVal = MsgBox.Input(minString,"Minimum Value",fieldmean.AsString)
maxVal = MsgBox.Input(maxString,"Maximum Value",fieldmean.AsString)
'select all the objects that meet the requirements
queryStringy = "(["+fieldchoice.GetAlias+"]>="+minVal+") and (["+fieldChoice.GetAlias+"]<="+maxVal+")"
isOK = themeChoiceFTab.Query(queryStringy,themeChoiceFTab.GetSelection,#VTAB_SELTYPE_NE)
themeChoiceFTab.UpdateSelection
av.GetProject.SetModified(true)
end 'while
returnVal = av.Run ("FS.IntersectThemes",usedThemeList)
'********************************************************************
'View.FindSame.ave
'Raj Singh, 1996
'This script finds the values of the selected fields of selected
'themes which underly the selected polygon. Then based on those
'values, the user can expand their range a bit and find all other
'areas on the map that fall within the range of values chosen for the
'selected themes.
'
'the update script should make sure only one theme is active and
'only one polygon is selected when this script is called
theView = av.GetActiveDoc
theObjectTheme = av.GetActiveDoc.GetActiveThemes.Get(0)
theFTab = av.GetActiveDoc.GetActiveThemes.Get(0).GetFTab
themeFieldList = List.Make
theThemeList = theView.GetThemes
themeFieldList = themeFieldList.Empty
usedThemeList = av.Run ("FS.SelectThemes","")
usedCount = usedThemeList.Count
returnVal = av.Run ("FS.IntersectThemes",usedThemeList)