Feature_class_from_postcodes Program
– with due acknowledgement to all the ArcGIS resources
This is a minor modification of the sample subroutine “MatchTable” from http://arcobjectsonline.esri.com
Instructions as to how to apply the code can be found at that web-site. I simply select a table in ArcCatalog and call “MatchTable” through a context menu item or a UIToolControl as described in Chapter 15 of Using ArcCatalog. (For Geocoding see Chapter 10 of Building a Geodatabase.)
Instead of using dialogs to identify what to use, my version uses the default geocoding service and geocodes the table already selected in the ArcCatalog menu. The subroutine seems to work for any table (with a geocoding “postcode” field) that displays properly in the Preview pane, i.e. all headers are alphanumeric, begin with a letter and are no more than 31 characters in length.
- The first sub-routine “GetLocatorFromPath” specifies that the default “geocoding service” (what ArcObjects calls a “locator” object) is to be used.
- This sub-routine is called in the MatchTable routine within an “if” block that depends on a variable “bBrowse” that I declared as “False” to avoid the browsing behaviour of the original program sample down-loaded from the ERSI web-site.
- The code just above sets the table object “pTable” to the table that is to be geo-coded. This is the table that has been selected in ArcCatalog.
- “GetAddressFieldNames” is used to get the name of the column of the table that matches the single-field of the “locator”.
- The “DerivedOutput” sub-routine checks to see if the table to be used for output already exists in the Access database “postcodes.mdb”. If it does then it is deleted.
- Most of the rest of the code in “MatchTable” deals with setting up the output “FeatureClass” in the Access database, with the final two short sections attaching the “geocoding service”.