This document is archived and information here might be outdated.  Recommended version.

How to find the address closest to a point using reverse geocoding (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Spatial query and analysis > Geocoding > Finding locations > How to find the address closest to a point using reverse geocoding

How to find the address closest to a point using reverse geocoding

While geocoding is used to find the point that corresponds to an address, reverse geocoding takes a point and finds the closest address.

In this topic

Finding the address closest to a point using reverse geocoding

When given a location on a map, if you want to find the address closest to that point, use reverse geocoding. The IReverseGeocoding and IReverseGeocodingProperties interfaces provide access to members for finding the address closest to a point.
  1. To define the maximum search tolerance in the units specified by the SearchDistanceUnits property, use the SearchDistance property when looking for an address represented by a point.

    The ReverseGeocode method returns a PropertySet that represents the address closest to the point passed as the location parameter.
The point object passed to the location parameter must be projected into the spatial reference used by the locator before it is passed to the ReverseGeocode parameter.
  1. Use the bReturnIntersection parameter to indicate whether the ReverseGeocode method should return an intersection address. The property names contained in the PropertySet correspond to the Field object names in the Fields collection returned by the AddressFields property on IAddressInputs on the locator. See the following code example:
public void ReverseGeocode()
    // Open a workspace from a file geodatabase.
    System.Object obj=Activator.CreateInstance(Type.GetTypeFromProgID(
    IWorkspaceFactory2 workspaceFactory=obj as IWorkspaceFactory2;
    IWorkspace workspace=workspaceFactory.OpenFromFile(@"C:\UnitedStates.gdb", 0);

    // Get a locator from the locator workspace.
    ILocatorManager2 locatorManager=obj as ILocatorManager2;
    ILocatorWorkspace locatorWorkspace=locatorManager.GetLocatorWorkspace
    IReverseGeocoding reverseGeocoding=(IReverseGeocoding)

    // Create a Point at which to find the address.
    IAddressGeocoding addressGeocoding=(IAddressGeocoding)reverseGeocoding;
    IFields matchFields=addressGeocoding.MatchFields;
    IField shapeField=matchFields.get_Field(matchFields.FindField("Shape"));
    IPoint point=new PointClass();
    point.X= - 117.2;

    // Set the search tolerance for reverse geocoding.
    IReverseGeocodingProperties reverseGeocodingProperties=

    // Find the address nearest the Point.
    IPropertySet addressProperties=reverseGeocoding.ReverseGeocode(point, false);

    // Print the address properties.
    IAddressInputs addressInputs=(IAddressInputs)reverseGeocoding;
    IFields addressFields=addressInputs.AddressFields;
    for (int i=0; i < addressFields.FieldCount; i++)
        IField addressField=addressFields.get_Field(i);
        Console.WriteLine(addressField.AliasName + ": " +
Public Sub ReverseGeocode()
    ' Open a workspace from a file geodatabase.
    Dim obj As System.Object=Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"))
    Dim workspaceFactory As IWorkspaceFactory2=obj
    Dim workspace As IWorkspace=workspaceFactory.OpenFromFile("C:\UnitedStates.gdb", 0)
    ' Get a locator from the locator workspace.
    Dim locatorManager As ILocatorManager2=obj
    Dim locatorWorkspace As ILocatorWorkspace=locatorManager.GetLocatorWorkspace(workspace)
    Dim locator As ILocator=locatorWorkspace.GetLocator("USLocator")
    Dim reverseGeocoding As IReverseGeocoding=locator
    ' Create a Point at which to find the address.
    Dim addressGeocoding As IAddressGeocoding=reverseGeocoding
    Dim matchFields As IFields=addressGeocoding.MatchFields
    Dim shapeField As IField=matchFields.Field(matchFields.FindField("Shape"))
    Dim point As IPoint=New Point
    ' Set the search tolerance for reverse geocoding.
    Dim reverseGeocodingProperties As IReverseGeocodingProperties=reverseGeocoding
    ' Find the address nearest the Point.
    Dim addressProperties As IPropertySet=reverseGeocoding.ReverseGeocode(point, False)
    ' Print the address properties.
    Dim addressInputs As IAddressInputs=locator
    Dim addressFields As IFields=addressInputs.AddressFields()
    For i As Integer=0 To addressFields.FieldCount - 1
        Dim addressField As IField=addressFields.Field(i)
        Console.WriteLine(addressField.AliasName + ": " + addressProperties.GetProperty(addressField.Name))
End Sub

See Also:

Location library overview
Sample: Find the closest intersection from a point
How to reverse geocode point features in a feature class

To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):

Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced