[an error occurred while processing this directive][an error occurred while processing this directive]
In the City of Phoenix, the City Clerk's Office is responsible for providing maps of the voter precincts and polling locations to the public, candidates, and political parties. Maps must be prepared for each major election in the city, and all the information must be kept up to date. The voter precincts for the City of Phoenix are created based on Maricopa County precincts, the county in which the city is located. The precinct configuration is affected by changes in boundaries of county precincts, population, and other political factors. Consequently, many of the city precincts have to be re-created for each election.
In addition, as mandated by an ordinance, each city precinct must have a designated polling location. Keeping all this information updated and organized seamlessly for each election using GIS basic operations presents a formidable task.
GIS has become popular for maintaining and manipulating spatial data. In 1990, the City Clerk's Office began using GIS to create election maps. GIS is now an important tool for preparing and maintaining maps and spatial data for elections.
The process of creating election layers involves steps such as data queries and GIS analysis and requires that the responsible personnel have high-level technical skills. Furthermore, some steps in the layer creation process must be repeated many times. As a result, the process is not only time consuming but also prone to errors.
To alleviate these problems, the City Clerk's Office decided to develop an application to automate the whole process of generating election layers that would include customizing, standardizing, and packaging all the required functionality in customized tools with a user-friendly interface for ArcMap. The primary advantage of such an application would be significantly shortening production time, producing more dependable results, and enhancing the user's experience. This article describes how to build an application that can retrieve time series data with a live link to an external database and use ArcObjects to convert attribute data to GIS geometries of spatial layers.
The modular, scalable, cross-platform architecture on which Esri's ArcGIS is based is composed of libraries of ArcObjects components. ArcObjects, the basic building blocks of ArcGIS, allows developers to expand ArcGIS functionalities and develop customized applications.
Phoenix's application has two toolsone for creating the polling location layer and the other for creating the city voter precinct layer. Both were created as customized tools in ArcMap using ArcObjects in Visual Basic for Applications (VBA) programming environment. For both tools, input data comes from a Microsoft Access database. GIS layers, which can be stored in a geodatabase, personal geodatabase, or in shapefile format, are the outputs. Both tools use existing layers as frames for new layers, copy created geometries (e.g., polygons of voter precincts and points of polling locations), and attribute data into them. These tools allow users to make copies of each layer before replacing existing features with new features.
Polling Location Layer Tool
The City of Phoenix uses public facilities as polling places. For each election, the city selects facilities from a candidate list based on availability and facility conditions and creates a polling location map. The names and addresses of polling locations are stored in an Access table that is used by the tool.
The tool uses each address to find a corresponding parcel in the GIS parcel layer and calculates the central point of the selected parcel from the polygon envelope. Addresses that cannot be found in the parcel layer are geocoded referencing street centerlines. The tool uses the coordinates of the central point and geocoding results to create point geometries. These point geometries and related attribute data make up the polling location layer. The entire process is programmed as a single button on the ArcMap interface. The tool provides several forms for users to locate data tables and select field names for required information.
City Precinct Layer Tool
Basically, the city precinct layer is created from combining county precincts. For each election, the City Clerk's Office must prepare a cross-reference table that has information on the relationship between city and county voter precincts and supplies the name and unique identification code for each precinct.
Based on the relationship between the two kinds of precincts defined in the cross-reference table, the county precincts for each city precinct are selected and the boundaries of all selected county precinct polygons are dissolved and combined into a larger single polygon. Like the polling location layer tool, the city precinct layer tool links and combines all needed functions and procedures into a single button. Once clicked, the tool guides users through the entire process from locating the data table and selecting requested fields to generating the voter precinct layer. The user only needs to point to the correct table and fields.
ArcObjects in ArcMap
Both custom tools are available as buttons on the Election toolbar in the ArcMap interface that can be turned on and off. The customized tools for creating the city voter precinct layer and polling location layer were created using objects from the Framework Library. Each tool is composed of a group of functions performing complex database connections, data queries, spatial operations, and other GIS analysis functions. The objects from the ArcMapUI library used in the tools are also responsible for accessing map documents and controlling how they are displayed and manipulated.
Display Control Functions
The tools use Display objects from the Carto Library to customize the user interface to display layers in a way that can be easily viewed and understood. To provide users with a visualization of the process, the tool redraws the entire view after each new polygon or point is created. When a tool is chosen, related layers are automatically turned on with predefined settings. The redrawing of each polygon or point using Display control objects while the application is still running provides an animation of the whole process.
Data Connection and Query Functions
The data required by both tools is stored in Access tables and accessed via Microsoft ActiveX Data Objects (ADOs). An ADO connection object is used to connect the application with data sources, and ADO Recordsets store and hold selected data. For creating the city precinct layer, the tool selects the names of all county precincts that make up each city precinct from the cross-reference table and stores the names and all other related information in ADO Recordsets. For the polling location, the tool selects and stores polling location names and related data in ADO Recordsets.
Instead of coding table and field names in the tools, both tools provide users with greater flexibility by giving users several specifically designed forms to locate and open data tables and select fields that contain necessary data. Built-in data query functions allow users to readily retrieve external data. Users do not have to name tables and fields with predefined names. As long as the data has the right format, the tools will be able to retrieve data to create election layers.
Spatial Processing and Geocoding Functions
During the process of creating the precinct layer, the spatial functions use Topological Operator objects from the Geodatabase library to construct new polygon geometry from the union of several geometries. The tool uses functions to combine county precincts to generate a city precinct according to the information stored in ADO Recordsets.
Based on the data in ADO Recordsets, the polling location tool uses spatial functions developed with Geometry objects to retrieve the envelope of each selected parcel polygon and calculate the center point coordinates from the envelope. Using the coordinate values, the tool creates point geometry for each polling location.
For the polling location addresses that do not have the corresponding parcels in the parcel layer, the polling location tool uses the geocoding process to locate these addresses along the street centerlines. Geocoding objects from the Location library provides the tool with access for validating the reference, geocoding these addresses into point geometries using street centerlines as a reference. The point geometries generated from central points of parcel polygons and geocoding together make up the polling location layer.
Both the city voter precinct and polling location tools are designed to use existing layers as frames to create new layers. New layers can be in one of the three data formatsan SDE feature class, a personal geodatabase, or a shapefile.
Before creating new polygons (for voter precincts) and points (for polling locations), the tools need to empty the existing layers. The tools use Geodatabase objects to open the database, make the layers editable, select and delete all records from existing layers, and let the user choose whether to make a copy of the existing layer before deleting all records.
If a user chooses to make a copy of the existing layer, the tool creates a new layer and copies all the records from the existing layer onto new layers based on the database and layer properties obtained by using appropriate Geodatabase objects. If a layer is on a geodatabase server, the function creates an SDE feature class with the same name and the time when the layer is copied. If the layer is in an Access database, the copy will be in a personal geodatabase. If the layer is in shapefile format, the copy will also be a shapefile in the same folder. Geodatabase objects are responsible for managing attributes. After the new geometries are created and inserted into layers, related attribute data is also copied into the layers.
Although the basic functions and tools needed to create and maintain election data are standard features of ArcGIS, users need to be trained to effectively use them because the process of creating election layers involves a number of different functions and tools. ArcGIS does not have built-in functions that allow for easy access to an external database.
In the City of Phoenix, the voter precinct layer has more than 100 polygons. This means users must repeat the same procedures for reclassifying precincts more than 100 times. The same difficulties exist when creating the polling location layer. Rather than using these tedious and error-prone processes, the City of Phoenix has developed customized ArcMap tools that automatically open and select required data from Access databases. All required procedures and functions are automated within the application through a user-friendly interface. Instead of going through the entire process manually, this application lets the user perform all the necessary tasks simply by clicking buttons. Moreover, users can enjoy viewing the whole process as a series of animated events.
ArcObjects is a remarkable technology that can greatly simplify the process of building customized GIS applications at different scales and for people with different levels of technical proficiency. Developed with modular system architecture, the application presented here can be easily expanded to suit other users' needs.
For more information, contact
The author thanks Dr. Gary Powell and Penny Webb of the Information Technology Department of the City of Phoenix for providing support for this project and reviewing the manuscript of this article. The author also thanks Penny Webb for her suggestions on this article.
About the Author
Wei Gao has master's degrees in ecology and environmental science from Miami University. She has worked on a variety of GIS analysis and application projects from scientific research to government services. She has been working for the City of Phoenix for six years, primarily developing Internet GIS applications and GIS desktop applications to extend and automate ArcGIS functionality using ArcObjects.