Home    |    Concepts   |   API   |   Samples
Concepts > Geocoding > Address Locators
Batch Geocoding Addresses

Some applications may require you to geocode a table of addresses using a locator. Although it can be done on an address-by-address basis, it is much more efficient to batch geocode the table using a server-side process.

SE_table_locate() geocodes a table of addresses in a single operation. It forces the processing to be performed in one step on the server side, eliminating unnecessary client-server traffic. It also takes care of many routine actions, like preparing the output layer, and copying original addresses to the output, which is often required by business applications. Results of the batch operation can be joined to the original address table using join columns, which are specified as parameters of this function.
 
/* helper macro to get a number of elements of a constant array */
#define ARR_DIM(array) (sizeof(array)/sizeof((array)[0]))

/* we assume the locator needs two columns: address and zipcode*/
const CHAR *input_columns[] = {"Cust_address", "ZIP"};

/* we want output layer to have a copy of the following
* columns from the original table */
const CHAR *columns_to_copy[] = {"Cust_name", "Cust_since", "Cust_status"};

/* use "OBJECTID" as the join (key) column;
* it will link the result back to the input_table */
const CHAR *key_columns[] = {"OBJECTID"};

rc = SE_table_locate(Connection, locator,
"customer_addresses", /** input_table */
"", /** where_clause is empty, process all */
ARR_DIM(input_columns), /** array of input columns */
input_columns,
ARR_DIM(key_columns), /** array of columns that will link */
key_columns, /* output layer back to the input table */
ARR_DIM(columns_to_copy), /** array of the columns to be */
columns_to_copy, /* carried over to the output layer */
"customer_locations", /* output layer name */
"DEFAULTS"); /* config_keyword; we'll just use "DEFAULTS" */

check_error(Connection, NULL, rc, "SE_table_locate");
/* We're done! */

After this operation, a new customer_locations layer will be created. This layer will have a copy of the locator used to create it stored in the layerís metadata. It will also contain a copy of the address columns from the address table.

Now, suppose you updated the addresses for some of the records and marked them by setting the values of the Cust_status field to MOVED. The following example shows how to use SE_table_rematch() to update the locations of these addresses.

/* couple of days later a customer moved to another address,
* so we modified its record in the address table and
* need to refresh the customerís location */
rc = SE_table_rematch(Connection,
NULL, /* NULL means "use the attached locator, as it is" */
"customer_locations", /* name of the table to be rematched */
"Cust_status = 'MOVED'"); /* re-process only addresses matching this criteria */
check_error(Connection, NULL, rc, "SE_table_rematch");

A geocoded layer can also be rematched while temporarily changing the geocoding settings used to create the layer, as in the following example. For more information on geocoding settings, see Geocoding in ArcGIS or the ArcGIS Desktop Help.

SE_LOCATORINFO *locator_list = NULL;
LONG num_locators;

/* get list of locators associated with the table
* (SE_table_locate() "attaches" copy of locator to the output layer) */
rc = SE_table_get_locator_list(Connection,
"customer_locations", /* result of SE_table_locate() */,
&locator_list,
&num_locators);

check_error(Connection, NULL, rc, "SE_table_get_locator_list");

/* relax locator's search by lowering value
* of the "MinimumMatchScore" property */
rc = SE_locatorinfo_set_single_property(locator_list[0],
"MinimumMatchScore",
"50"); /* relax MinimumMatchScore
* to get more address matches
* (be aware of false positives!) */
check_error(Connection, NULL, rc, "SE_locatorinfo_set_single_property");

/* use the updated locator for re-processing the output layer */
rc = SE_table_rematch(Connection,
locator_list[0], /* use the updated locator */
"customer_locations", /* name of the layer to be rematched */
""); /* empty where clause -- rematch all addresses */
check_error(Connection, NULL, rc, "SE_table_rematch");

/* free locator list as it is no longer needed */
SE_table_free_locator_list(num_locators, locator_list);
Send your comments to: Site Administrator | Terms of Use | PRIVACY | Copyright © ESRI.