Address text geocoded to a location with the geocoding service
What is address geocoding?
Address geocoding, also known as forward geocoding, is the process of converting text for an address to a complete address with a location. For example, you can convert 1 Bridge St, Sydney, Australia
to 1 Bridge St, Sydney, New South Wales, 2000
.
You can use address search to:
- Geocode address text to a complete address.
- Find the location of an address.
- Provide a list of address candidates for an incomplete address.
How address geocoding works
You can geocode an address by making an HTTPS request to the geocoding service find
operation or by using client APIs. Specify the address, output data fields, and optionally, additional parameters to refine the search.
The more complete you can make the input address, the more likely the geocoding service will find an exact match. For example, "1600 Pennsylvania Ave NW, Washington, District of Columbia, 20500".
To refine the search, you can provide additional parameters such as the location, search extent, country code, city, and neighborhood.
The geocoding service parses the address and uses all of the parameters to return a set of address candidates. Each candidate contains a full address, location, attributes, and a score of how well it matched. By default the address, score, and location are returned, but to return all of the data fields available, you can set the outFields parameter to *****.
URL request
https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?address={searchText}&outFields={fieldList}&f=json&token=<ACCESS_TOKEN>
Required parameters
Name | Description | Examples |
---|---|---|
f | The format of the data returned. | f=json f=pjson |
token | An API key or OAuth 2.0 access token. | token= |
Key parameters
Name | Description | Examples |
---|---|---|
address | The address or place name. Different formats are supported. | address=1600 Pennsylvania Ave NW,DC address=Washington,DC address=81301 address=-117.155579,32.703761 |
out | The list of data fields to return. | outFields=PlaceName,Addr_type, outFields=* (return all fields) |
Additional parameters: Refine the search by using parameters such as location
, search
, neighborhood
, city
, and country
. Use lang
to return results in a specific language.
Storage parameter
If you need to store or persist the geocoding service results in any way, you are required to use the for
parameter.
Name | Description | Example |
---|---|---|
for | Specifies whether the results of the operation will be persisted. | for |
Code examples
Geocode an address
This example illustrates how to geocode address text. Most APIs provide a LocatorTask to access the service.
Steps
-
Reference the geocoding service.
-
Set the address.
-
Set the token to your API key.
The response is a set of address candidates with a full address, location, and score.
Address text geocoded to a location.
APIs
const geocodingServiceUrl = "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";
const params = {
address: {
"address": "1600 Pennsylvania Ave NW, DC"
}
}
locator.addressToLocations(geocodingServiceUrl, params).then((results) => {
showResult(results);
});
REST API
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates \
-d 'f=pjson' \
-d 'address=1600 Pennsylvania Ave NW, DC' \
-d 'token=<ACCESS_TOKEN>'
Tutorials
Search for an address
Convert an address or place to a location with the geocoding service.