arcgis.geocoding module

The arcgis.geocoding module provides types and functions for geocoding, batch geocoding and reverse geocoding.

Geocoders can find point locations of addresses, business names, and so on. The output points can be visualized on a map, inserted as stops for a route, or loaded as input for spatial analysis. It is also used to generate batch results for a set of addresses, as well as for reverse geocoding, i.e. determining the address at a particular x/y location.

Geocoder

class arcgis.geocoding.Geocoder(location, gis=None)

Geocoders can find point locations of addresses, business names, and so on. The output points can be visualized on a map, inserted as stops for a route, or loaded as input for spatial analysis. It is also used to generate batch results for a set of addresses, as well as for reverse geocoding, i.e. determining the address at a particular x/y location.

A GIS includes one or more geocoders, that can be queried using get_geocoders(gis).

Geocoders shared as Items in the GIS can be obtained using Geocoder.fromitem(item).

Geocoders may also be created using the constructor by passing in their location, such as a url to a Geocoding Service.

classmethod fromitem(item)

Creates a Geocoder from an Item in the GIS :param item: an Item of type ‘Geocoding Service’ :return: Geocoder

properties

The properties of this object

get_geocoders

geocoding.get_geocoders(gis)

A GIS includes one or more geocoders. The list of geocoders registered with the GIS can be queried using get_geocoders. :param gis: the GIS whose registered geocoders are to be queried :return: list of geocoders registered with the GIS

geocode

geocoding.geocode(address, search_extent=None, location=None, distance=None, out_sr=None, category=None, out_fields='*', max_locations=20, magic_key=None, for_storage=False, geocoder=None, as_featureset=False)

The geocode function geocodes one location per request.

Argument Description
address

required list of strings or dictionaries. Specifies the location to be geocoded. This can be a string containing the street address, place name, postal code, or POI.

Alternatively, this can be a dictionary containing the various address fields accepted by the corresponding geocoder. These fields are listed in the addressFields property of the associated geocoder. For example, if the address_fields of a geocoder includes fields with the following names: Street, City, State and Zone, then the address argument is of the form: {

Street: “1234 W Main St”, City: “Small Town”, State: “WA”, Zone: “99027”

}

search_extent optional string, A set of bounding box coordinates that limit the search area to a specific region. This is especially useful for applications in which a user will search for places and addresses only within the current map extent.
location optionl [x,y], Defines an origin point location that is used with the distance parameter to sort geocoding candidates based upon their proximity to the location.
distance optional float, Specifies the radius of an area around a point location which is used to boost the rank of geocoding candidates so that candidates closest to the location are returned first. The distance value is in meters.
out_sr optional dictionary, The spatial reference of the x/y coordinates returned by a geocode request. This is useful for applications using a map with a spatial reference different than that of the geocode service.
category optional string, A place or address type which can be used to filter find results. The parameter supports input of single category values or multiple comma-separated values. The category parameter can be passed in a request with or without the text parameter.
out_fields optional string, name of all the fields to inlcude. The default is “*” which means all fields.
max_location optional integer, The number of locations to be returned from the service. The default is 20.
magic_key The find operation retrieves results quicker when you pass a valid text and magickey value.
for_storage Specifies whether the results of the operation will be persisted. The default value is false, which indicates the results of the operation can’t be stored, but they can be temporarily displayed on a map for instance. If you store the results, in a database for example, you need to set this parameter to true.
geocoder Optional, the geocoder to be used. If not specified, the active GIS’s first geocoder is used.
as_featureset optional boolean, if True, the result set is returned as a FeatureSet object, else it is a dictionary.
Returns:dictionary

reverse_geocode

geocoding.reverse_geocode(location, distance=None, out_sr=None, lang_code=None, return_intersection=False, for_storage=False, geocoder=None)

The reverse_geocode operation determines the address at a particular x/y location. You pass the coordinates of a point location to the geocoding service, and the service returns the address that is closest to the location.

Returns:dictionary

batch_geocode

geocoding.batch_geocode(addresses, source_country=None, category=None, out_sr=None, geocoder=None, as_featureset=False)

The batch_geocode() function geocodes an entire list of addresses. Geocoding many addresses at once is also known as bulk geocoding.

Returns:dictionary or FeatureSet

suggest

geocoding.suggest(text, location, distance=None, category=None, geocoder=None)

The result of this operation is a resource representing a list of suggested matches for the input text. This resource provides the matching text as well as a unique ID value, which links a suggestion to a specific place or address. A geocoder must meet the following requirements to support the suggest operation:

The address locator from which the geocoder was published must support suggestions. Only address locators created using ArcGIS 10.3 for Desktop and later can support suggestions. See the Create Address Locator geoprocessing tool help topic for more information. The geocoder must have the Suggest capability enabled. Only geocoders published using ArcGIS 10.3 for Server or later support the Suggest capability.

The suggest operation allows character-by-character auto-complete suggestions to be generated for user input in a client application. This capability facilitates the interactive search user experience by reducing the number of characters that need to be typed before a suggested match is obtained. A client application can provide a list of suggestions that is updated with each character typed by a user until the address they are looking for appears in the list.