Skip To Content

Geocode Locations

Description

Batch Geocode

The GeocodeLocations operation geocodes a table from a big data file share. The task uses a geocode utility service configured with your portal. If you do not have a geocode utility service configured, talk to your administrator. Learn more about configuring a locator service.

When preparing to use the GeocodeLocations operation, be sure to review Best practices for geocoding with GeoAnalytics.

Request parameters

ParameterDetails
inputLayer

(Required)

The tabular input that will be geocoded.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST Examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"inputLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}
geocodeParameters

(Required)

This includes parameters that help parse the input data as well as the field lengths and a field mapping. This JSON is the output from the AnalyzeGeocodeInput tool available on your server designated to geocode. It is important to inspect the field mapping closely and adjust them accordingly before submitting your job, otherwise your geocoding results may not be accurate. It is recommended that you use the output from AnalyzeGeocodeInput and modify the field mapping instead of constructing this JSON by hand.

REST Examples

//REST web example
{"field_info": "[('ObjectID', 'TEXT', 255), ('SingleLine', 'TEXT', 255), ('Address', 'TEXT', 255), ('Region', 'TEXT', 255), ('Postal', 'TEXT', 255), ('PostalExt', 'TEXT', 255), ('Country', 'TEXT', 255), ('Source', 'TEXT', 255)]", "column_names": "", "file_type": "csv", "column_delimiter": ",", "text_qualifier": "", "field_mapping": "[['ObjectID', 'OBJECTID'], ['SingleLine', 'SingleLine'], ['Address', 'Address'], ['Region', 'Region'], ['Postal', 'Postal'], ['PostalExt', 'PostalExt'], ['Country', ''], ['Source', '']]", "header_row_exists": true}

//REST scripting example
"geocodeParameters": {"field_info": "[('ObjectID', 'TEXT', 255), ('SingleLine', 'TEXT', 255), ('Address', 'TEXT', 255), ('Region', 'TEXT', 255), ('Postal', 'TEXT', 255), ('PostalExt', 'TEXT', 255), ('Country', 'TEXT', 255), ('Source', 'TEXT', 255)]", "column_names": "", "file_type": "csv", "column_delimiter": ",", "text_qualifier": "", "field_mapping": "[['ObjectID', 'OBJECTID'], ['SingleLine', 'SingleLine'], ['Address', 'Address'], ['Region', 'Region'], ['Postal', 'Postal'], ['PostalExt', 'PostalExt'], ['Country', ''], ['Source', '']]", "header_row_exists": true}
geocodeServiceURL

(Required)

The REST URL of the geocode service that you want to geocode your addresses against. The URL must end in geocodeServer and allow batch requests. The geocode service must be configured to allow for batch geocoding. For more information, see Configuring batch geocoding

REST Examples

//REST web example
{"url": "https://mymachine.mydomain.com/server/rest/services/my_locator/GeocodeServer"}

//REST scripting example
"geocodeServiceURL": {"url": "https://mymachine.mydomain.com/server/rest/services/my_locator/GeocodeServer"}
sourceCountry

(Optional)

Enter a sourceCountry if all of your data is from the same country. Some geocoding services do not support sourceCountry, and the available options depend on your geocode service.

REST Examples

//REST web example
US

//REST scripting example
"sourceCountry": "Canada"
category

(Optional)

Enter a category for more precise geocoding results, if applicable. Some geocoding services do not support category, and the available options depend on your geocode service.

REST Examples

//REST web example
POI

//REST scripting example
"category": "address"
includeAttributes

(Optional)

A Boolean value to return the output fields from the geocoding service in the results. To output all available outputFields, set this value to true. Setting the value to false will return your original data with geocode coordinates. Some geocoding services do not support outputFields, and the available options depend on your geocode service.

REST Examples

//REST web example
true

//REST scripting example
"outputFields": "false"
locatorParameters

(Optional)

Additional parameters specified to your locator.

outputName

(Required)

The task will create a feature service of the results. You define the name of the service.

REST Examples

//REST web example
myOutput

//REST scripting example
"outputName": "myOutput"
context

(Optional)

Context contains additional settings that affect task execution. For this task, there are three settings:

  • Processing spatial reference (processSR)—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR)—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore)—Results will be saved to the specified data store. The default is the spatiotemporal big data store.
f

The response format. The default response format is html.

Values: html | json

Example usage

Below is a sample request URL for GeocodeLocations:

https://hostname.domain.com/webadaptor/rest/services/System/GeoAnalyticsTools/GPServer/GeocodeLocations/submitJob?inputLayer={"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}&geocodeParameters={"field_info": "[('ObjectID', 'TEXT', 255), ('SingleLine', 'TEXT', 255), ('Address', 'TEXT', 255), ('Region', 'TEXT', 255), ('Postal', 'TEXT', 255), ('PostalExt', 'TEXT', 255), ('Country', 'TEXT', 255), ('Source', 'TEXT', 255)]", "column_names": "", "file_type": "csv", "column_delimiter": ",", "text_qualifier": "", "field_mapping": "[['ObjectID', 'OBJECTID'], ['SingleLine', 'SingleLine'], ['Address', 'Address'], ['Region', 'Region'], ['Postal', 'Postal'], ['PostalExt', 'PostalExt'], ['Country', ''], ['Source', '']]", "header_row_exists": true}&geocodeServiceURL={"url": "https://mymachine.mydomain.com/server/rest/services/my_locator/GeocodeServer"}&outputName=myOutput&f=json

Response

When you submit a request, the service assigns a unique job ID for the transaction.

Syntax:
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically check the status of the job and messages as described in Check job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<analysis url>/GeocodeLocations/jobs/<jobId>

Access results

When the status of the job request is esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

https://<analysis-url>/GeocodeLocations/jobs/<jobId>/results/output?token=<your token>&f=json

ResponseDescription
output

output is a point layer. Features that failed to find a geocode match will not have any coordinates.

{"url": "https://<analysis-url>/BatchGeocode/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.