The ArcGIS Geocoding service supports batch geocoding a file of addresses in CSV (comma-separated values) or zipped CSV format utilizing the batch
endpoint.
The capabilities of batch
are the same as the geocodeAddresses operation. These are the primary differences—
- With
batch
, the input addresses are passed to the service in a file; withGeocode geocode
, the addresses are passed to the service as a collection of JSON objects.Addresses - The
batch
process is executed as a job whose status can be monitored, and it does not block, nor is blocked by, other geocoding operations running concurrently.Geocode
The batch
workflow is recommended for larger geocoding scenarios, where 100,000 or more addresses need to be geocoded.
Access the services
To access the geocoding service you need the following:
- An ArcGIS Location Platform account or ArcGIS Online account.
- An access token (API key or OAuth 2.0) with the appropriate privilege.
batchGeocode workflow
Using batch
to batch geocode a file of addresses involves a sequence of steps whereby the output from one operation is used as the input for the next operation. The final output is a downloadable file that includes the original address rows with the x and y coordinates of the geocoded locations appended to them, along with additional informational fields describing the geocoding results. These are the same output fields returned in the JSON response by the geocode
operation. Each step must be completed in order for the file to be geocoded successfully.
- Upload the address file. Upload the file of addresses to the server using
add
. The JSON response includes anItem id
value for the item which is used in the next step. - Submit the geocoding job to the service. Pass the item
id
from theadd
response, map the fields in your file to the input fields supported by the service, and include any additional geocoding parameters usingItem submit
. This produces an outputJob job
value which is used in the next step.Id - Check the job status. Pass the
job
value from theId submit
response in aJobs jobs
request to check the status of thebatch
job. When the returnedGeocode status
value isSUCCEEDED
proceed to the next step. - Obtain the URL to download the geocoded file. Make a second
jobs
request to obtain a URL which is used to download the geocoded file. This request must also include thejob
value from the previous steps.Id - Download the file. Pass the download URL from the previous step in a final step to download the file that includes the batch geocoding results.
Upload the address file
Use the add
operation to upload the file of addresses to the portal. The result of the add
request is an item id
property in the JSON response that is associated with the uploaded file of addresses. The id
value must be used in subsequent steps to complete the batch geocoding process.
The input file must adhere to the following requirements:
- The file must be in CSV (.csv) or zipped CSV (.zip) format.
- The file must use UTF-8 encoding with a BOM (byte order mark).
- The maximum file size supported by the ArcGIS Geocoding service is 2 GB. If you have a CSV file that exceeds 2 GB you must compress it as a zipped file or reduce the number of records in the file before submitting it to the service.
- The filename must be unique for the ArcGIS Online user. If the file already exists as an item in the portal, you can get its ID and use it as the
id
value in subsequent batch geocoding workflow steps. Alternatively you can delete the item using the Delete Items API call and reupload it usingadd
.Item
Request URL
https
Request parameters
Parameter value | Description |
---|---|
token (Required) | Use this parameter to specify an access token that provides the identity of a user who has the needed permissions to access the service. See Security and authentication for more information about how to generate an access token. |
file (Required) | The file name of the address file to be geocoded. |
Refer to the add
topic for complete details about adding a file to a portal.
Example
{
"success": true,
"id": "dbbf2fed71784aec9815e91190da5239",
"folder": ""
}
Submit the geocoding job to the service
Use the submit
operation to start the geocoding job. The id
value returned in the response for the add
request in the previous step, as well as a token
, must be passed in the submit
request.
Additionally, a field mapping definition must be included in the submit
request, which aligns the fields in your CSV file with the input fields expected by the ArcGIS Geocoding service. The supported input fields are described in the findAddressCandidates topic. Optional geocoding parameters to refine results may also be included in the request. The additional geocoding parameters are documented in the geocodeAddresses topic.
The result of the submit
operation is a job
value that is associated with the geocoding job. This job
value must be used in all subsequent steps to complete the batch geocoding process.
Request URL
https
Request parameters
Parameter value | Description |
---|---|
token (Required) | Use this parameter to specify an access token that provides the identity of a user who has the needed permissions to access the service. See Security and authentication for more information on how to generate an access token. |
item (Required) | The |
fieldMapping (Required) | Use this parameter to map the fields in your address table to the input fields expected by the service. The mapping should follow this general format:
If the entire address is stored in a single field in your file, map it to the SingleLine input field. For instance, if the address field in your file is named "full_address", the SingleLine example
If the addresses are split up into individual components, such as street address, city, state, and postal code, map them to the multiline input fields supported by the service. This is referred to as multiline or multifield geocoding. The fields should be separated by commas. As an example, your address file may include the following fields:
In this case, the Multiline example
|
Additional geocoding parameters (Optional) | There are many optional parameters that can be used to refine or adjust the geocoding results. These are described in detail in the geocodeAddresses topic. |
Example
POST https://geocode-beta.arcgis.com/arcgis/rest/services/World/GeocodeServer/batchGeocode/beta/submitJob HTTP/1.1
content-type: application/x-www-form-urlencoded
User-Agent: <USER AGENT>
item = {'itemID': 'f507a5ddf4f9485c8f8ac6dc6ad9f25f'}
&token=<ACCESS_TOKEN>
&fieldMapping=Address:street_address,City:municipality,Region:state,Postal:zip_code
&<PARAMETERS>
Check the job status
Use the jobs
operation to check the status of the geocoding job. The job
value returned in the submit
response must be passed in the jobs
request. Additionally, a token
must be included in the jobs
request.
The jobs
operation allows you to monitor the progress of the geocoding job. As you periodically send jobs
requests to the service, informational responses are returned which describe the current state of the job. When the geocoding job is complete, the jobs response indicates that the job was successful and provides a URL to the geocoded file. The URL will be used in the next step to download the file.
The job
value in the response from the submit
request must be appended to end of the jobs
request URL.
Request URL
https
Request parameters
Parameter value | Description |
---|---|
token (Required) | Use this parameter to specify an access token that provides the identity of a user who has the needed permissions to access the service. See Security and authentication for more information on how to generate an access token. |
Example
This is an example jobs request which can be submitted periodically to get the current state of the geocoding job.
Request
POST https://geocode-beta.arcgis.com/arcgis/rest/services/World/GeocodeServer/batchGeocode/beta/jobs/7aaae43b-b47e-43d1-bff1-75f2d2d2d33f HTTP/1.1
content-type: application/x-www-form-urlencoded
User-Agent: <USER AGENT>
&token=<ACCESS_TOKEN>
As the geocoding job progresses, the job
and status
values in the response change according to the status of the job.
Sample response 1
{
"jobId": "7aaae43b-b47e-43d1-bff1-75f2d2d2d33f",
"jobStatus": "esriJobSubmitted",
"status": "SUBMITTED",
"messages": []
}
Sample response 2
{
"jobId": "7aaae43b-b47e-43d1-bff1-75f2d2d2d33f",
"jobStatus": "esriJobSubmitted",
"status": "RUNNABLE",
"messages": []
}
Sample response 3
{
"jobId": "7aaae43b-b47e-43d1-bff1-75f2d2d2d33f",
"jobStatus": "esriJobSubmitted",
"status": "STARTING",
"messages": []
}
Sample response 4
{
"jobId": "7aaae43b-b47e-43d1-bff1-75f2d2d2d33f",
"jobStatus": "esriJobExecuting",
"status": "RUNNING",
"messages": []
}
Sample response 5
{
"jobId": "7aaae43b-b47e-43d1-bff1-75f2d2d2d33f",
"jobStatus": "esriJobExecuting",
"status": "RUNNING",
"messages": [
{
"description": "Job is 50% complete geocoding...",
"type": "esriJobMessageTypeInformative"
}
]
}
When the geocoding job is complete, the job
value in the response is esri
. Additional information describing the geocoding results is also in the response. Most importantly, the results
object in the response includes the value for the param
object. This information will be used in the next step to access the URL for downloading the geocoded file.
Final response
{
"jobId": "7aaae43b-b47e-43d1-bff1-75f2d2d2d33f",
"jobStatus": "esriJobSucceeded",
"status": "SUCCEEDED",
"messages": [
{
"description": "Total Matched/Tied/Unmatched: 469/26/5",
"type": "esriJobMessageTypeInformative"
}
],
"results": {
"geocodeResult": {
"paramUrl": "results/geocodeResult"
}
}
}
Obtain the download URL
The jobs
operation is also used to obtain the URL for downloading the output file that contains the batch geocoding results. As with the previous step for checking the status of the geocoding job, the job
value returned in the submit
response must be passed in the jobs
request. Additionally, a token
must be included in the jobs
request.
When job
value in the jobs
response from the previous step is esri
, send a second jobs
request by appending the value of the param
object to the end of the jobs
request URL.
Request URL
https
Request parameters
Parameter value | Description |
---|---|
token (Required) | Use this parameter to specify an access token that provides the identity of a user who has the needed permissions to access the service. See Security and authentication for more information on how to generate an access token. |
Example
POST https://geocode-beta.arcgis.com/arcgis/rest/services/World/GeocodeServer/batchGeocode/beta/jobs/7aaae43b-b47e-43d1-bff1-75f2d2d2d33f/results/geocodeResult HTTP/1.1
content-type: application/x-www-form-urlencoded
User-Agent: <USER AGENT>User-Agent: <USER AGENT>
token: <ACCESS TOKEN>
Download the file
The final step in the batch
process is to download the zipped CSV file that contains the batch geocoding results. The URL for the download is included in the response for the previous jobs
request in the url
object.
Request parameters
Parameter value | Description |
---|---|
token (Required) | Use this parameter to specify an access token that provides the identity of a user who has the needed permissions to access the service. See Security and authentication for more information on how to generate an access token. |
Example
GET https://geocode-beta.arcgis.com/rest/services/World/GeocodeServer/batchGeocode/beta/download/7aaae43b-b47e-43d1-bff1-75f2d2d2d33f.zip HTTP/1.1
User-Agent: <USER AGENT>
Accept-Encoding: br,gzip
token: <ACCESS TOKEN>
Failed requests
When requests cannot be completed, messages describing the problem are returned by the service. This can be due to invalid parameters included in the request or insufficient user permissions. Some potential errors that may be encountered with the service are described below.
Error messages
Error code 403
Message | Details | Cause | ExtendedCode |
---|---|---|---|
Token is valid but access is denied. | User does not have permissions to store geocoding results. | This error is returned when a user with insufficient privileges attempts to geocode a file using the | none |
Error code 409
Message | Details | Cause | ExtendedCode |
---|---|---|---|
Item '{item name}' already exists. | none | This error is returned when an item already exists in the portal with the same name as the filename passed in the | none |
Error code 500
Message | Details | Cause | ExtendedCode |
---|---|---|---|
Invalid token. | none | This error is returned when an expired or otherwise invalid access token is included in a | none |
Failed jobs
The batch
process may fail if there is a problem with the input CSV file or if the field mapping is incorrect. In these situations, the status returned by the jobs
request will indicate the issue.
Invalid input file format
If the uploaded file is not in the required format, the response for the subsequent jobs request will indicate that the job failed.
{
"status": "FAILED",
"logs": "Failed to process input file. Please check that the file is a valid CSV or ZIP file."
}
Invalid service input field
If the field mapping passed in the submitJob request includes a reference to a service input field name which does not exist, the response for the subsequent jobs request will indicate that the job failed and identify the invalid field name.
{
"status": "FAILED",
"logs": "Wrong field mapping. Locator has no input field <invalid field>"
}
Invalid CSV field
If the field mapping passed in the submitJob request includes a reference to a nonexistent field name in the input CSV file, the response for the subsequent jobs request will indicate that the job failed and identify the invalid field name. The error is also returned if a field name passed in the field
parameter of the submit
request uses different casing than the corresponding field name in the CSV file. For example, if the field name in the CSV file is CITY
, but the name specified in the field
is City
, this error is returned.
{
"status": "FAILED",
"logs": "Wrong field mapping. CSV file has no column <invalid field>"
}
Bad CSV header
If there is a problem with the input CSV file's header, the response for the subsequent jobs request will indicate that the job failed and return the following message.
{
"status": "FAILED",
"logs": "Can't read csv header"
}