Batch geocoding

Three text strings geocoded in one transaction with the geocoding service

Three text strings geocoded in one transaction with the geocoding service

What is batch geocoding?

Batch geocoding, also known as bulk geocoding, is the process of converting a list of addresses or place names to a set of complete addresses with locations. The list of addresses can be formatted as a JSON structure or provided in a CSV file.

Batch geocoding is commonly used to:

  • Convert a number of addresses to complete addresses.
  • Find the locations for a list of addresses.
  • Perform large batches of geocoding.
  • Geocode addresses that can be saved for future use.

How batch geocoding works

The geocoding service parses each address and using the parameters you provide, returns a set of geocoded address locations. Each returned location contains a full address, x and y coordinates, attributes, and a score of how well it matched.

There are two ways to batch geocode addresses:

  1. Provide addresses as JSON input and use geocodeAddresses.
  2. Provide address data as file input and use batchGeocode.

JSON input

To geocode a list of addresses you can use the geocodeAddresses direct request. The input is a list of addresses as a JSON collection, and optionally, additional parameters to refine the output. The output is returned as a list of records with addresses.

To keep track of each input and output address, the input values should contain an objectid field to connect the input data record to the output address candidate returned (see ResultID).

JSON format

The JSON format requires a record with attributes for each address string to geocode:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "records": [
  {
  "attributes": {
      "objectid": 1,
      "address": "Buckingham Palace"
  }
  ...
}

To refine the geocoded address output, provide additional parameters such as the search extent, location type, category, and source country.

File input

To geocode a file of addresses, use the batchGeocode job request. The input can be either a CSV (.csv) file or a zipped CSV (.zip) file, along with a case-sensitive key-value list that maps the fields in your file to those required by the service. The output is returned as a file of addresses with locations, along with additional informational fields describing the geocoding results (in CSV format).

This method requires a job request with the following steps:

  1. Add the file of addresses to your portal.
  2. Submit the job request to the service.
  3. Monitor the status of your request.
  4. Access the results file URL.
  5. Download the result file.

File Format

The format of the input CSV file can contain address data in multiple columns or in a single column.

Address data in multiple columns:

Use dark colors for code blocksCopy
1
2
3
4
5
Address,City,State,Postal
11270 SW CINDY ST,Portland,OR,97008
16360 SW ESTUARY DR,Portland,OR,97006
13895 SW MERIDIAN ST,Portland,OR,97005
...

Address data in a single column:

Use dark colors for code blocksCopy
1
2
3
4
5
Addresses
"380 New York St, Redlands, CA"
"1 World Way, Los Angeles, CA"
"1200 Getty Center Drive, Los Angeles, CA
...

URL requests

Direct (geocodeAddresses)

Use the geocodeAddresses operation to batch geocode a list of addresses.

Use dark colors for code blocksCopy
1
https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses?<parameters>

Learn more about standard and enhanced endpoints in Service endpoints.

Required parameters

NameDescriptionExamples
fThe format of the data returned.f=json f=pjson
tokenAn access token (API key or OAuth 2.0) with the required premium:user:geocode:stored privilege.

Go to Security and authentication to generate an access token.
token=<ACCESS_TOKEN>

Key parameters

NameDescriptionExamples
addressesA JSON object with an address or place name. Different address formats are supported.See example

Additional parameters: Refine the search results by using parameters such as searchExtent, locationType, category, countryCode. Use langCode to return results in a specific language.

Job (batchGeocode)

Use the batchGeocode operation to geocode a file with a large number of addresses. The file needs to be uploaded with the addItem operation before submitting the job. To see all of the steps required for the job request, go to Geocode a file of addresses (code example).

Use dark colors for code blocksCopy
1
https://geocode-beta.arcgis.com/arcgis/rest/services/World/GeocodeServer/batchGeocode/beta/submitJob

Required parameters

NameDescriptionExamples
tokenAn access token (API key or OAuth 2.0) with the required premium:user:geocode:stored privilege.

Go to Security and authentication to generate an access token.
token={ACCESS_TOKEN}
itemThe item ID returned in the response from the addItem request.item={"itemID":"c1ffa12e2f554101bc7cb737d9245413"}
fieldMappingA list of key:value strings mapping the fields in your address file to the input fields expected by the service.fieldMapping="Address:Address, City:City, Region:State, Postal:Postal"

Code examples

Direct: Geocode a set of addresses

Use the geocodeAddresses direct request to find the locations for a list addresses.

Steps

  1. Reference the geocoding service.
  2. Set the addresses to be geocoded. All input addresses should include an objectid field.
  3. Set the token parameter to your API key.

The response contains a set of geocoded addresses. The input objectid matches the output ResultID for each record. Addr_type represents whether the input address resolved to a standard address or POI. score represents how well it matched.

Three text strings geocoded in one transaction with the geocoding service

Use the geocodeAddresses operation to find the location of many addresses.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS API for PythonArcGIS REST JSEsri LeafletMapLibre GL JSOpenLayersCesiumJS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
          const geocodingServiceUrl =
            "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"

          const params = {
            addresses: [
              {
                objectid: 1,
                address: "Buckingham Palace",
              },
              {
                objectid: 2,
                address: "Abeno Restaurant London",
              },
              {
                objectid: 3,
                address: "58 Brewer Street, London, England",
              },
            ],
          }

          locator.addressesToLocations(geocodingServiceUrl, params).then(
            results => {
              if (results.length) {
                results.forEach(result => {
                  addGraphic(result)
                })
              }
            },
            function(error) {
              console.log(error)
            }
          )
Expand

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
curl https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses \
-d 'f=pjson' \
-d 'addresses=
    {
        "records": [
           {
            "attributes": {
                "objectid": 1,
                "address": "Buckingham Palace"
            }
            },
            {
                "attributes": {
                    "objectid": 2,
                    "address": "Bernardis Restaurant London"
                }
            },
            {
                "attributes": {
                    "objectid": 3,
                    "address": "58 Brewer Street, London, England"
                }
            }
        ]
    }' \
-d 'token=<ACCESS_TOKEN>'

Job: Geocode a file of addresses

Use the batchGeocode job request to find the locations for a file of addresses.

Steps

  1. Upload a CSV(.csv) or zipped CSV (.zip) to the geocoding service.
  2. Submit the job request.
  3. Check the job status.
  4. Access the URL to the result file.
  5. Download the result file.

Input file (.csv)

AddressCityStatePostal
11270 SW CINDY STPortlandOR97008
16360 SW ESTUARY DRPortlandOR97006
13895 SW MERIDIAN STPortlandOR97005
...

Result output file (.csv)

ShapeXShapeYLoc_nameStatusScoreMatch_addrLongLabelShortLabelAddr_typePlace_addrRankAddNumStPreDirStNameStTypeStAddrCitySubregionRegionRegionAbbrPostalPostalExtCountryCntryNameLangCodeDistanceXYDisplayXDisplayYXminXmaxYminYmaxAddressCityStatePostal
-122.79333445.465578WorldM99.08180311270 SW Cindy St, Beaverton, Oregon, 9700811270 SW Cindy St, Beaverton, OR, 97008, USA11270 SW Cindy StPointAddress11270 SW Cindy St, Beaverton, Oregon, 9700820.00000011270SWCindySt11270 SW Cindy StBeavertonWashington CountyOregonOR970085885USAUnited StatesENG0.000000-122.79333345.465758-122.79333445.465578-122.794334-122.79233445.46457845.46657811270 SW CINDY STPortlandOR97008
-122.84390245.514404WorldM99.08180316360 SW Estuary Dr, Beaverton, Oregon, 9700616360 SW Estuary Dr, Beaverton, OR, 97006, USA16360 SW Estuary DrPointAddress16360 SW Estuary Dr, Beaverton, Oregon, 9700620.00000016360SWEstuaryDr16360 SW Estuary DrBeavertonWashington CountyOregonOR970067929USAUnited StatesENG0.000000-122.84395345.513692-122.84390245.514404-122.844902-122.84290245.51340445.51540416360 SW ESTUARY DRPortlandOR97006
-122.82204645.502979WorldM99.08180313895 SW Meridian St, Beaverton, Oregon, 9700513895 SW Meridian St, Beaverton, OR, 97005, USA13895 SW Meridian StPointAddress13895 SW Meridian St, Beaverton, Oregon, 9700520.00000013895SWMeridianSt13895 SW Meridian StBeavertonWashington CountyOregonOR970052476USAUnited StatesENG0.000000-122.82274345.503274-122.82204645.502979-122.823046-122.82104645.50197945.50397913895 SW MERIDIAN STPortlandOR97005
...

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
    submit_url = BATCH_URL + "/submitJob"
    params = {
        "fieldMapping": FIELD_MAPPING,
        "item": {"itemID": item.id},
        "token": token,
    }
    if not use_get:
        response = requests.post(submit_url, json=params)
    else:
        response = requests.get(submit_url, params=params)

    json_response = response.json()
    if json_response.get("error") is not None:
        print(json_response)
        sys.exit()

    job_id = json_response["jobId"]
    print("Job submitted for geocoding")
Expand

REST API

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

POST /sharing/rest/content/users/{USER_NAME}/addItem HTTP/1.1
Host: www.arcgis.com
Content-Length: 1214
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="f"

json
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="token"

{ACCESS_TOKEN}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="addresses.csv"
Content-Type: text/csv

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="title"

MyAddressFile
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="type"

CSV
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="typeKeywords"

CSV, Text, Data
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="description"

This is a csv file uploaded programmatically for use with the batchGeocode(beta) service
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="tags"

postman, batchGeocode, csv, addresses
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Response (JSON)
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

{
  "success": true,
  "id": "{ITEM_ID}",
  "folder": ""
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.