ArcGIS REST API

Geocode Locations

Batch Geocode

The Geocode Locations task 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.

Request URL

http://<analysis url>/GeocodeLocations/submitJob

Request parameters

ParameterDescription

inputLayer

The tabular input that will be geocoded.

Syntax: As described in detail in the Feature input topic, 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 web example:

  • {"url" : "http://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

REST scripting example:

  • "inputLayer" : {"url": "http://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 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 to use the output from AnalyzeGeocodeInput and modify the field mapping instead of constructing this JSON by hand.

Values

  • field_info—A list of triples with the field names of your input data, the field type (usually TEXT), and the allowed length (usually 255). A sample input looks like [['ObjectID', 'TEXT', 255], ['Address', 'TEXT', 255], ['Region', 'TEXT', 255], ['Postal', 'TEXT', 255]]
  • header_row_exists—Enter true or false.
  • column_names—Submit the column names of your data if your data does not have a header row.
  • field_mapping—Field mapping between each input field and candidate fields on the geocoding service. Example: [['ObjectID', 'OBJECTID'], ['Address', 'Address'], ['Region', 'Region'], ['Postal', 'Postal']]

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 web example:

  • {"url": "http://mymachine.mydomain.com/server/rest/services/my_locator/GeocodeServer"}

REST scripting example:

  • "geocodeServiceURL": {"url": "http://mymachine.mydomain.com/server/rest/services/my_locator/GeocodeServer"}

sourceCountry

Optionally, 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 web example:

  • US

REST scripting example:

  • "sourceCountry": "Canada"

category

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 web example:

  • POI

REST scripting example:

  • "category": "address"

includeAttributes

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 and with geocode coordinates. Some geocoding services do not support outputFields, and the available options depend on your geocode service.

REST web example:

  • true

REST scripting example:

  • "outputFields":"false"

locatorParameters

Additional parameters specific to your locator.

outputName

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

REST scripting example: "outputName" : "myOutput"

REST web example: myOutput

context

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

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 Checking 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:

http://<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:

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

ParameterDescription

output

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

Request example:
{"url": 
"http://<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.