Select to view content in your preferred language

Locator won't match close street number in single address locator

13640
77
11-26-2013 06:49 AM
PeterHanmore
Emerging Contributor
We have built a locator in ArcGIS 10 SP5 which is based on the US Street - Single Address style.
We have been able to tweak most other settings but are still having issues with street number scoring.
Basically, we would like the locator to rank similar house numbers on the same street/town with a high score.
The default action (from my testing and based on one other forum thread) seems to indicate that the locator is VERY strict about the house number matching - to the point that it will give a high ranking to an address that matches the house number and street in a town hundreds of miles away, but fail to even score the address 100' away.
We have tried playing with the scoring of the FullNormalAddress, NormalAddress and House components but nothing seems to allow addresses with close house numbers in the desired city to be ranked higher than exact house number matches in a different city.

For example:
Search for 100 Main Street, Mytown

Geocoder responds with:
Score: 90, Address: 100 Main Street, Yourtown (could be large distance away from Mytown and therefore totally wrong location).

Yet 98 Main Street, Mytown is only two house numbers away from the desired address.  I would like the locator to return something like:

Score: 98, Address: 98 Main Street, MyTown
Score: 50, Address: 100 Main Street, Yourtown

Has anyone found a solution for this?  Any workarounds?  Apparently this worked as desired in 9.3.1 but was "improved" in 10.0?
Tags (2)
77 Replies
ElizabethWare1
Emerging Contributor

What is happening, is CAD/Mobile creates a call. The list of active calls are then put into a csv file where it is created into a shape file and added to the map.

0 Kudos
BradNiemand
Esri Regular Contributor

Elizabeth,

When you say created into a shape file do you mean that the CSV file is geocoded with the locator to create the shape file?

I am not an ArcObjects expert but can get my way around the geocoding ArcObjects code.  If the CSV is getting geocoded, I would be curious as to how it is getting done right now because I might have an easier way to do it with geoprocessing in C#.

Brad

0 Kudos
ElizabethWare1
Emerging Contributor

Well I can't get passed opening it. I keep getting a useless error that tells me nothing. If you know of another way, I am all ears. All this worked great for 9.3. Here is the code for creating the shape from a csv.

IWorkspaceFactory pFact = new TextFileWorkspaceFactory();
IWorkspace pWorkspace = pFact.OpenFromFile(LocalFolder, 0);

IFeatureWorkspace pFeatws = (IFeatureWorkspace)pWorkspace;
ITable pTable = pFeatws.OpenTable(CSVFile); //open the .csv file...  !!! Can't get passed this part.

ShapefileWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();

IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(LocalFolder, 0);


pMatchFields = geocoder.MatchFields; // Fields from Locator
pTableFieldsEdit = (IFieldsEdit)pTable.Fields; // Fields from ActiveCalls.csv
pOutputFields = (IFieldsEdit)new Fields();
pTableFields = pTableFieldsEdit;
pOutputFields.FieldCount_2 = pTableFields.FieldCount + pMatchFields.FieldCount + 1;

pFieldEdit = (IFieldEdit)new Field();
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
pFieldEdit.Name_2 = "FID";

// Add FID Field
pOutputFields.set_Field(0, pFieldEdit);

// add the fields from the .csv table
for (int i = 1; i <= pTableFields.FieldCount; i++)
pOutputFields.set_Field((i), pTableFields.get_Field(i - 1));

// add the match fields From Locator
for (int i = (1 + pTableFields.FieldCount); i <= (pMatchFields.FieldCount + pTableFields.FieldCount); i++)
{
pOutputFields.set_Field(i, pMatchFields.get_Field(i - pTableFields.FieldCount - 1));
}

// Create the feature class.
pFeatureClass = pFeatureWorkspace.CreateFeatureClass(ShapeFileName, pOutputFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");

// create the set of output field names
for (int i = 0; i <= pMatchFields.FieldCount - 1; i++)
{
strOutputFieldNames = strOutputFieldNames + pMatchFields.get_Field(i).Name;
if (i != pMatchFields.FieldCount - 1)
{
strOutputFieldNames = strOutputFieldNames + ",";
}
}

pPropertySet = new PropertySet();

for (int i = 0; i <= pTableFields.FieldCount - 1; i++)
{
pPropertySet.SetProperty(pTableFields.get_Field(i).Name, pTableFields.get_Field(i).Name);
}

strAddressFieldNames = GetAddressFieldNames((IAddressInputs)geocoder, pTable);

ITrackCancel trackCancel = new CancelTrackerClass();


// Geocode the Addresses.....
geocoder.MatchTable(pTable, strAddressFieldNames, "", pFeatureClass, strOutputFieldNames, pPropertySet, trackCancel);


// attach the locator to the geocoded feature class for future use in re-geocoding...
pLocatorDataset = (ILocatorDataset)geocoder;
pLocatorAttach = (ILocatorAttach2)pLocatorDataset.LocatorWorkspace;
pLocatorAttach.AttachLocator((ILocator)geocoder, (ITable)pFeatureClass, strAddressFieldNames, strOutputFieldNames);

}
catch (Exception e)
{
MessageBox.Show("Error when geocoding file. " + e.Message);

0 Kudos
BradNiemand
Esri Regular Contributor

Elizabeth,

Yeah that code is the hard way to do it .  All of that code can be replaced by this.  You just need to change the path to the table, locator and where you want the geocoded featureClass to go.  Also, the field mapping is "LocatorFieldName TableFieldName" with each field separated with a semicolon.  The 10.x locators have had the same field names for some time so I think Street,City,State,Zip should be the same for you too.  You will just need to put in the table field names to replace ADDRESS,CITY,STATE,ZIP below.

You will also need the following using:

using ESRI.ArcGIS.Geoprocessing;

public void GeocodeAddressesTool()
{
String table = @"C:\geocoding\redlands\redlands_addr.csv";
String locator = @"C:\geocoding\redlands\redlands_points_locator"; 

String fieldMapping = "Street ADDRESS;" + "City CITY;" + "State STATE;" + "Zip ZIP";
String outputFC = @"C:\geocoding\redlands\redlands_addr_geocoded";

IVariantArray parameters = new VarArrayClass();
parameters.Add(table);
parameters.Add(locator);
parameters.Add(fieldMapping);
parameters.Add(outputFC);

IGeoProcessor GP = new GeoProcessorClass();
GP.OverwriteOutput = true;
object Missing = System.Type.Missing;

try
{
GP.Execute("GeocodeAddresses_geocoding", parameters, null);
}
catch (Exception e)
{
throw new Exception("Tool threw an exception: " + e.Message + " GP Messages: " + GP.GetMessages(ref Missing));
}
}

0 Kudos
ElizabethWare1
Emerging Contributor

This will create the shape need on the map? This replaces all of that? That would be awesome. I am not as familiar with this. I know a bit and how it worked in 9.3, but have very little experience with ArcGIS in general. So this help is greatly appreciated.Hopefully, this will get me passed this part and on to the next.

I am going out for a bit, but will be sure to try this when I get back.

0 Kudos
BradNiemand
Esri Regular Contributor

Elizabeth,

It will do everything that you did above but with a lot less code.  It will create a shapefile with all of the geocoding results in it as well as all of the original input data fields copied into the geocoded featureClass as well.  Essentially it is doing the exact thing that happens when using the GeocodeAddresses GP tool in ArcMap so you should get exactly the same output as you got in ArcMap.

Brad

0 Kudos
ElizabethWare1
Emerging Contributor

This gives me an error when trying to create the GeoProcessorClass. It says "Interop type can't be embedded. Use the applicable interface instead." And I need to get a count of Active Calls.

0 Kudos
BradNiemand
Esri Regular Contributor

Elizabeth,

Go to the Project references and make sure that the ESRI.ArcGIS.Geoprocessing assembly has the property "Embed Interop Types" set to false.

Brad

0 Kudos
ElizabethWare1
Emerging Contributor

Ok fixed the embedded error. But I do the GP.Execute and I get this error:

I have seen this with another program too and have not figured out what is causing it.

0 Kudos
BradNiemand
Esri Regular Contributor

Elizabeth,

I can't guarantee this will work but try disabling multithreading in the locator and see if that helps.

Brad

0 Kudos