Geocode service GeocodeAddress method

Geocodes a single address and returns a single result.

GeocodeAddress(PropertySet Address, PropertySet PropMods)

Parameter

Description

Address

Address information stored as a PropertySet to be geocoded. Each property is associated with an address field defined for the geocoding service. Use GetAddressFields() to get a list of fields.

PropMods

Modifications to the geocode service properties. Use GetLocatorProperties() to get a list of default locator properties. Use GetLocatorProperties() to return default locator properties.

Return Value

A PropertySet containing property-values pairs defining the best match found by the geocode service. The names of these properties are defined by the names of the Field objects returned by the GetResultFields() method.

Remarks

The following diagram illustrates the geocode server proxy methods commonly used when working with the GeocodeAddress() method. In addition, the diagram also includes the input (address) and output (match) information one can expect when using this method.

Common geocode server GeocodeAddress proxy methods

The input Address parameter is a PropertySet containing the address to geocode and find the best match. The names of the properties in this object are the names of the address fields used by the geocode service. Use the GetAddressFields() method to retrieve the definitions of the address fields used by the geocode service, and use the names of these fields as the names of the properties defined in the Address PropertySet. Each Field object has a Required property which indicates if the address field is required by the geocode service. Failing to specify a required address property will return an error.

The PropMods parameter is a PropertySet containing the geocode service properties to use to find candidates for the address. The GetLocatorProperties() method returns the set of default geocoding properties for the geocode service. In some cases, you may want to modify the geocoding properties used to determine the best location for an address. For example, you may wish to change the spelling sensitivity used to search for a match for the address, or you may want to change the side and end offset applied to the geocoded location. Modify the properties in the PropertySet returned by the GetLocatorProperties() method and pass the modified PropertySet as the PropMods parameter. The PropertySet only needs to contain properties that are different than the default properties for the geocode service. If you do not need to modify any of the default properties returned used by the geocode service, the PropertySet parameter can be null or you can pass the unmodified PropertySet returned by the GetLocatorProperties() method.

Using pre-ArcGIS 10 locators

In some cases you may want to find candidates for an address that has already been standardized (thus the geocode service will not standardize any address input). Use the GetStandardizedFields() or GetStandardizedIntersectionFields() methods to retrieve the names of the standardized address fields used by the geocode service, and use the names of these fields as the names of the properties defined in the address PropertySet. You must also add an additional property to the address PropertySet to indicate that the address is a standardized address. The name of this property must be "ADDR_TYPE", and its value must be "A" for a standardized address, or "I" for a standardized intersection. The PropertySet only needs to contain properties that have a value, even if the standardized field is listed as required.

Examples

C#

GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";

 

// Define address inputs

PropertySet geocodePropSet = new PropertySet();

PropertySetProperty[] propArray = new PropertySetProperty[2];

PropertySetProperty geocodeProp = new PropertySetProperty();

 

geocodeProp.Key = "Street";

// Intersection

//geocodeProp.Value = "Magnolia & Central"

// Address

geocodeProp.Value = "5950 Magnolia Avenue";

propArray[0] = geocodeProp;

 

PropertySetProperty geocodeProp1 = new PropertySetProperty();

geocodeProp1.Key = "Zone";

geocodeProp1.Value = "92506";

propArray[1] = geocodeProp1;

 

geocodePropSet.PropertyArray = propArray;

 

// Geocode address

PropertySet results = geocodeservice.GeocodeAddress(geocodePropSet, null);

PropertySetProperty[] resultsArray = results.PropertyArray;

PointN geocodePoint = null;

 

foreach (PropertySetProperty result in resultsArray)

{

      string val = result.Key.ToString();

      if (result.Key == "Shape")

      {

            geocodePoint = result.Value as PointN;

            double x = geocodePoint.X;

            double y = geocodePoint.Y;

      }

}

VB.NET

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

' Define address inputs

Dim geocodePropSet As PropertySet = New PropertySet()

Dim propArray(1) As PropertySetProperty

Dim geocodeProp As PropertySetProperty = New PropertySetProperty()

geocodeProp.Key = "Street"

 

' Intersection

'geocodeProp.Value = "Magnolia & Central";

' Address

geocodeProp.Value = "5950 Magnolia Avenue"

propArray(0) = geocodeProp

 

Dim geocodeProp1 As PropertySetProperty = New PropertySetProperty()

geocodeProp1.Key = "Zone"

geocodeProp1.Value = "92506"

propArray(1) = geocodeProp1

 

geocodePropSet.PropertyArray = propArray

 

'Geocode address

Dim results As PropertySet = geocodeservice.GeocodeAddress(geocodePropSet, Nothing)

Dim resultsArray() As PropertySetProperty = results.PropertyArray

Dim geocodePoint As PointN = Nothing

Dim result As PropertySetProperty

 

For Each result In resultsArray

      Dim val As String = result.Key.ToString()

      If result.Key = "Shape" Then

            geocodePoint = CType(result.Value, PointN)

            Dim x As Double = geocodePoint.X

            Dim y As Double = geocodePoint.Y

      End If

Java

String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";

GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);

 

String street = "1 Main St.";

String zip = "94105";

 

PropertySetProperty[] address = new PropertySetProperty[2];

 

//Set street

PropertySetProperty streetProp = new PropertySetProperty();

streetProp.setKey("STREET");

streetProp.setValue(street);

address[0] = streetProp;

 

//Set zip

PropertySetProperty zoneProp = new PropertySetProperty();

zoneProp.setKey("ZONE");

zoneProp.setValue(zip);

address[1] = zoneProp;

 

//Input geocode property set

PropertySet geocodeProp = new PropertySet();

geocodeProp.setPropertyArray(address);

     

//Geocode address

PropertySet results = geocodeService.geocodeAddress(geocodeProp, null);

 

for (PropertySetProperty result : results.getPropertyArray()) {

      if (result.getKey().equalsIgnoreCase("Shape")) {

            PointN geocodePoint = (PointN) result.getValue();

            double x = geocodePoint.getX();

            double y = geocodePoint.getY();

            System.out.println("XY: " + x + ", " + y);

     }

}// for

2/28/2020