scripting in atlas gis version 4 - esri · in a new visual basic project, choose components from...

2
Applications 42 ArcUser July–September 1999 www.esri.com How It Works Scripts are developed using programming languages such as Visual Basic by loading the AtlasMap OCX onto the form at design time. The AtlasMap control requires both the script developer and the end user to have Atlas GIS Version 4.0 installed. Once the AtlasMap control is loaded onto the form, more than 140 Atlas GIS functions and methods are available for use in the script application. Developers can design interfaces to Atlas GIS using the AtlasMap OCX and code that causes the program to display only particular page elements or map frames. A script can be used to create a dialog box for the user to input parameters so the program can execute a specific set of commands based on those parameters. The AtlasMap OCX can also be used to Automate repetitive tasks in code. Fill dialog boxes with specific default values or use code to execute the defaults automatically. Take advantage of the programming language’s functionality (i.e., use Data Access in Visual Basic). Run file merges or feature splits as batch operations. Putting AtlasMap OCX to Work In the following example a script written in Visual Basic handles the multiple commands necessary to answer the query, “How many households are there within 50 miles of all cities in the State of California?” The script will perform the following procedures in Atlas GIS: 1. Select the state feature based on a value (_NAME = “California”). 2. Select all cities in the selected state. 3. Create a new Region layer that will hold the 50-mile buffers around the cities. 4. Create buffers around the cities. 5. Create a new table to link to the buffered features using the table structure from the linked Counties table. 6. Aggregate from Counties table to the Buffers table. 7. Generate statistics based on an attribute of the aggregated buffers. In a new Visual Basic project, choose Components from the Project menu and load the AtlasMap.ocx. It will appear as an icon in the toolbox. Add the AtlasMap control to an MDIForm. In a procedure such as the Form_Load event, initialize Atlas GIS with the following code: AtlasRunning = AtlasMap1.AInit(“”) When Atlas GIS is running, a page window from Atlas GIS exists as a child form of the MDIForm. Load the data to be used in the script by using the code below. In the following example, the project Counties.prj consists of one geofile, Scripting in Atlas GIS Version 4.0 Atlas GIS scripting is here! The new AtlasMap ActiveX OCX from ESRI provides a way to create applications that use the functionality of Atlas GIS Version 4.0. By Sam Berg, Atlas GIS Product Specialist Counties.agf, with three layers, County:States, County:Cities, and County:Counties, that are linked to Counties.dbf using CNTY_FIPS as the key column. With MDIForm1.AtlasMap1 sPRJName = “c:\AtlasGIS\Data\Counties.prj” .AtlFileReadPrj sPRJName, A_PRJ_ALL Figure 1 contains code that selects features in the State layer by using the Query By Value command in Atlas GIS. The code in Figure 2 selects all the cities located in California, supplies the parameters for the Query | Select by Location | Inside dialog box, and executes the dialog box without displaying it. New/Casual Advanced User Level

Upload: phamthien

Post on 13-May-2018

215 views

Category:

Documents


2 download

TRANSCRIPT

Applications

42 ArcUser July–September 1999 www.esri.com

How It WorksScripts are developed using programming languages such as VisualBasic by loading the AtlasMap OCX onto the form at design time. TheAtlasMap control requires both the script developer and the end userto have Atlas GIS Version 4.0 installed. Once the AtlasMap control isloaded onto the form, more than 140 Atlas GIS functions and methodsare available for use in the script application.

Developers can design interfaces to Atlas GIS using the AtlasMapOCX and code that causes the program to display only particular pageelements or map frames. A script can be used to create a dialog boxfor the user to input parameters so the program can execute a specificset of commands based on those parameters. The AtlasMap OCX canalso be used to• Automate repetitive tasks in code.• Fill dialog boxes with specific default values or use code to execute the defaults automatically.• Take advantage of the programming language’s functionality (i.e., use Data Access in Visual Basic).• Run file merges or feature splits as batch operations.

Putting AtlasMap OCX to WorkIn the following example a script written in Visual Basic handles themultiple commands necessary to answer the query, “How manyhouseholds are there within 50 miles of all cities in the State ofCalifornia?”

The script will perform the following procedures in Atlas GIS:1. Select the state feature based on a value (_NAME = “California”).2. Select all cities in the selected state.3. Create a new Region layer that will hold the 50-mile buffers around the cities.4. Create buffers around the cities.5. Create a new table to link to the buffered features using the table structure from the linked Counties table.6. Aggregate from Counties table to the Buffers table.7. Generate statistics based on an attribute of the aggregated buffers.

In a new Visual Basic project, choose Components from the Projectmenu and load the AtlasMap.ocx. It will appear as an icon in thetoolbox. Add the AtlasMap control to an MDIForm. In a proceduresuch as the Form_Load event, initialize Atlas GIS with the followingcode:

AtlasRunning = AtlasMap1.AInit(“”)

When Atlas GIS is running, a page window from Atlas GIS exists as achild form of the MDIForm.

Load the data to be used in the script by using the code below. In thefollowing example, the project Counties.prj consists of one geofile,

Scripting in Atlas GIS Version 4.0

Atlas GIS scripting is here!The new AtlasMap ActiveX OCX from ESRI provides a way to createapplications that use the functionality of Atlas GIS Version 4.0.

By Sam Berg, Atlas GIS Product Specialist

Counties.agf, with three layers, County:States, County:Cities, andCounty:Counties, that are linked to Counties.dbf using CNTY_FIPSas the key column.

With MDIForm1.AtlasMap1sPRJName = “c:\AtlasGIS\Data\Counties.prj”.AtlFileReadPrj sPRJName, A_PRJ_ALL

Figure 1 contains code that selects features in the State layer by usingthe Query By Value command in Atlas GIS.

The code in Figure 2 selects all the cities located in California,supplies the parameters for the Query | Select by Location | Insidedialog box, and executes the dialog box without displaying it.

New/Casual Advanced

User Level

Applications

www.esri.com ArcUser July–September 1999 43

Figure 2,cont.

The same technique can be used to set the values for and execute theAggregate Data by Location dialog box to aggregate from theCounties layer to the Buffers layer. At this point each buffer featurewill have the same attributes as the Counties layer features. To answerthe original question, “How many households are there within 50miles of all cities in the State of California?,” the attribute POP00must be summed for each buffer.

There are several methods to calculate the cumulative value for eachof the buffers. One method is to turn on and calculate a theme for theBuffers layer. If the theme settings include each feature, a theme canbe queried to receive statistical values for the layer such as the sum.See the code in Figure 3.

After executing this code, the theme itself can provide the statisticalvalue by using the following code:

Sum = .AtlThemeGetInt(tLayerID,“LyrTheme0.Stats.Sum”)

Use scripting with the AtlasMap OCX to customize nearly everyaspect of Atlas GIS, and use code to fully control GIS and mappingfunctions. The AtlasMap OCX is available free of charge. VisitArcUser Online for links to download AtlasMap OCX.

Inland Color to DropAd Here

Virtual Campus1/3 PAGE Square.

New-ESRI

Dog Creek Design1/6-PAGE

New