织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

Locator—ArcGIS Pro

时间:2025-10-11 17:30来源: 作者:admin 点击: 4 次
ArcPy class for performing geocoding operations.

geocode (searchText, forStorage, {preferredSearchLocation}, {countryCode}, {categories}, {locationType}, {outFields}, {maxResults}, {minScore}, {outputLanguageCode}, {preferredLabelValues}, {searchExtent})

Parameter   Explanation   Data Type  

searchText

 

The address or place-name for which to find the location.

  String  

forStorage

 

Specifies whether the results will be stored. The default value is False, which indicates the results won't be stored, but they can be temporarily displayed on a map. If you store the results, in a database, for example, set this parameter to True.

This parameter only applies to geocoding requests made with ArcGIS World Geocoding Service. For all other locators, the parameter is ignored.

Note: Applications are contractually prohibited from storing the results of geocoding operations using ArcGIS World Geocoding Service unless they make the request by passing the forStorage parameter with a value of True. For a locator using ArcGIS World Geocoding Service to be valid, you must sign in to ArcGIS Online with a valid organizational account. ArcGIS Online service credits are deducted from the organizational account for each geocode transaction.

  Boolean  

preferredSearchLocation

 

The origin point that will be used to prefer or boost geocoding candidates based on their proximity to the location. Candidates near the location are prioritized relative to those farther away.

  PointGeometry  

countryCode

 

A comma-delimited string of three-character country codes that limits geocoding results to the set of specified countries, which will improve the accuracy of geocoding in most cases. When no country is specified, geocoding with suggestions is performed using all countries supported by the locator.

If you are using ArcGIS World Geocoding Service, see the list of supported countries.

  String  

categories

 

A comma-separated list of categories that limits the types of places the locator searches, eliminating false positive matches and potentially speeding up the search process. See the REST API web help for details about category filtering.

  String  

locationType

 

Specifies the preferred output location that will be used for PointAddress matches. If the preferred location does not exist in the data, the default location will be returned instead.

This parameter only affects the geometry, not the attribute values.

rooftopAn address location such as rooftop location, parcel centroid, or front door will be used. This is the default.

streetA location close to the side of the street that can be used for vehicle routing will be used.

  String  

outFields

 

The list of fields that will be returned as part of the attributes in the result. This parameter supports a single field name or a comma-delimited string of field names (with no spaces). To return the default output fields, outFields does not need to be passed. Use an asterisk ("*") to return all available output fields with the result. The output fields are described in What's included in the geocoded results.

  String  

maxResults

 

The maximum number of locations, up to the maximum number allowed by the locator. If no value is provided, all matching candidates up to the maximum specified in the Locator properties will be returned.

  Integer  

minScore

 

Limits the candidates that are returned to those with a score above the value set for this parameter. Valid values are between 0 and 100.

  Integer  

outputLanguageCode

 

The language in which the geocode results will be returned. Since addresses and places in many countries are available in more than one language, this ensures that results are returned in the expected language.

If you are using ArcGIS World Geocoding Service, see the list of supported countries for the language codes that are supported for those countries.

  String  

preferredLabelValues

 

Configures the output fields returned in a response from the locator by specifying the address component values that should be included in the output fields. The parameter supports a single value or a comma-delimited string of values as input. For more information about how this parameter works, see Additional tuning options.

Possible values include postalCity, localCity, matchedCity, primaryStreet, and matchedStreet.

Note:

Only one value for city labeling and one value for street labeling can be included.

  String  

searchExtent

 

An extent that limits the area that will be searched. All results that are returned outside of the specified extent will be excluded.

  Extent  

Return ValueData Type   Explanation  
List  

The output of the geocode operation is a list of dictionary objects. Each dictionary object represents a single geocoding result. Each geocoding result contains information about the match address or location, geometry information including x- and y-coordinates, and additional attributes depending on the Locator object used and the outFields value specified.

 

Note:If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS Pro. To access a locator that is on a portal other than your active portal, you can authenticate using SignInToPortal.

Geocode to find the location of a place or address using a locator on disk.

import arcpy # Create a new Locator object from a locator on disk locator_path = r"C:\Locators\Atlanta.loc" locator = arcpy.geocoding.Locator(locator_path) # Geocode to find the location of an address geocoding_candidates = locator.geocode("1670 W Peachtree St NE, Atlanta, GA 30309", False)

Geocode to find the location of a place or address using ArcGIS World Geocoding Service.

import arcpy # Create a new Locator object from the ArcGIS World Geocoding Service locator_path = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service" locator = arcpy.geocoding.Locator(locator_path) # Geocode to find the location of an address geocoding_candidates = locator.geocode("1670 W Peachtree St NE, Atlanta, GA 30309", True)

Geocode to find the location of a place or address using a locator accessed through an AGS connection.

import arcpy # Create a new Locator object from a locator published to ArcGIS Server locator_path = r"C:\AGS Files\MyAGSConnectionFile.ags\Atlanta" locator = arcpy.geocoding.Locator(locator_path) # Geocode to find the location of an address geocoding_candidates = locator.geocode("1670 W Peachtree St NE, Atlanta, GA 30309", False)

reverseGeocode (location, forStorage, {featureTypes}, {locationType}, {outputLanguageCode}, {preferredLabelValues})

Parameter   Explanation   Data Type  

location

 

A point for which you want to find the nearest address, point of interest, or intersection.

  PointGeometry  

forStorage

 

Specifies whether the results will be stored. The default value is False, which indicates the results won't be stored, but they can be temporarily displayed on a map. If you store the results, in a database, for example, set this parameter to True.

This parameter only applies to geocoding requests made with ArcGIS World Geocoding Service. For all other locators, the parameter is ignored.

Note:

Applications are contractually prohibited from storing the results of geocoding operations using ArcGIS World Geocoding Service unless they make the request by passing the forStorage parameter with a value of True. For a locator using ArcGIS World Geocoding Service to be valid, you must sign in to ArcGIS Online with a valid organizational account. ArcGIS Online service credits are deducted from the organizational account for each geocode transaction that includes the forStorage parameter with a value of True.

(The default value is False)

  Boolean  

featureTypes

 

The match types that will be returned. If only one value is provided, the search tolerance is adjusted.

For more information on how this parameter is used in ArcGIS World Geocoding Service, see the REST API documentation.

  String  

locationType

 

Specifies the preferred output location that will be used. If the preferred location does not exist in the data, the default location will be returned instead. For more information about this parameter, see the Reverse Geocode REST API documentation.

This parameter only affects the geometry, not the attribute values.

rooftopAn address location such as rooftop location, parcel centroid, or front door will be used. This is the default.

streetA location close to the side of the street that can be used for vehicle routing will be used.

  String  

outputLanguageCode

 

The language in which the reverse geocode results will be returned. Since addresses and places in many countries are available in more than one language, this ensures that results are returned in the expected language.

If you are using ArcGIS World Geocoding Service, see the list of supported countries for the language codes that are supported for those countries.

  String  

preferredLabelValues

 

Configures the output fields returned in a response from the locator by specifying the address component values that should be included in the output fields. The parameter supports a single value or a comma-delimited string of values as input. For more information about how this parameter works, see Additional tuning options.

Possible values include postalCity, localCity, matchedCity, primaryStreet, and matchedStreet.

Note:

Only one value for city labeling and one value for street labeling can be included.

  String  

Return ValueData Type   Explanation  
List  

The reverse geocoding result contains information about the match address or location, geometry information including x- and y-coordinates, and additional attributes depending on the Locator object used and the Shape key when the value is a PointGeometry object.

 

Note:If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS Pro. To access a locator that is on a portal other than your active portal, you can authenticate using SignInToPortal.

Reverse geocode to find the nearest place or address to a given location using a locator on disk.

import arcpy # Create a new Locator object from a locator on disk locator_path = r"C:\Locators\Atlanta.loc" locator = arcpy.geocoding.Locator(locator_path) # Create input PointGeometry object spatial_reference = arcpy.SpatialReference(4326) point = arcpy.Point(-84.374, 33.797) point_geometry = arcpy.PointGeometry(point, spatial_reference) # Reverse geocode to find the nearest address or place to the point reverse_geocode_result = locator.reverseGeocode(point_geometry, False)

Reverse geocode to find the nearest place or address to a given location using ArcGIS World Geocoding Service.

import arcpy # Create a new Locator object from the ArcGIS World Geocoding Service locator_path = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service" locator = arcpy.geocoding.Locator(locator_path) # Create input PointGeometry object spatial_reference = arcpy.SpatialReference(4326) point = arcpy.Point(-84.374, 33.797) point_geometry = arcpy.PointGeometry(point, spatial_reference) # Reverse geocode to find the nearest address or place to the point geocoding_candidates = locator.reverseGeocode(point_geometry, True)

Geocode to find the nearest place or address to a given location using a locator accessed through an AGS connection.

import arcpy # Create a new Locator object from a locator published to ArcGIS Server locator_path = r"C:\AGS Files\MyAGSConnectionFile.ags\Atlanta" locator = arcpy.geocoding.Locator(locator_path) # Create input PointGeometry object spatial_reference = arcpy.SpatialReference(4326) point = arcpy.Point(-84.374, 33.797) point_geometry = arcpy.PointGeometry(point, spatial_reference) # Reverse geocode to find the nearest address or place to the point geocoding_candidates = locator.reverseGeocode(point_geometry, False)

suggest (searchText, {preferredSearchLocation}, {countryCode}, {categories}, {maxResults}, {preferredLabelValues}, {returnCollections}, {searchExtent})

Parameter   Explanation   Data Type  

searchText

 

The partial text that will be used to generate suggestions.

  String  

preferredSearchLocation

 

The origin point that will be used to prefer or boost suggestion candidates based on their proximity to the location. Candidates near the location are prioritized relative to those farther away.

  PointGeometry  

countryCode

 

A comma-delimited string of three-character country codes that limits suggestion results to the set of specified countries, which will improve the accuracy of suggestions in most cases. When no country is specified, suggestions will be generated from all countries supported by the locator.

If you are using ArcGIS World Geocoding Service, see the list of supported countries in Geocode data coverage.

  String  

categories

 

A comma-separated list of categories that limits the types of places the locator uses to generate suggestions, eliminating false positive matches and potentially speeding up the process. See the REST API web help for details about category filtering.

  String  

maxResults

 

The maximum number of suggestions that will be returned, up to the maximum number allowed by the locator. If no value is provided, all matching suggestions up to the maximum specified by the maxSuggestCandidates property in the Locator properties will be returned.

  Integer  

preferredLabelValues

 

Configures the output fields returned in a response from the locator by specifying the address component values that should be included in the output fields. The parameter supports a single value or a comma-delimited string of values as input. For more information about how this parameter works, see Additional tuning options.

Possible values include postalCity, localCity, matchedCity, primaryStreet, and matchedStreet.

Note:

Only one value for city labeling and one value for street labeling can be included.

  String  

returnCollections

 

Specifies whether collections (points of interest [POI] categories) will be returned when searching for POI. For more information about how to use the returnCollections parameter, see .

When this parameter is False, if the first character is associated with a category that exists in the data used to build a locator based on the , the category name will not be included in the list of POI candidates returned.

(The default value is True)

  Boolean  

searchExtent

 

An extent that limits the area that will be searched. All results that are returned outside of the specified extent will be excluded.

  Extent  

Return ValueData Type   Explanation  
List  

The output of the suggest method is an array of dictionary objects. Each dictionary represents a single suggestion result. Each suggestion result contains the text, magicKey, and isCollection keys.

To use the output of this method, pass the entire dictionary at the desired index of the list to the geocodeWithSuggest method.

Note:To learn more about the dictionary keys, see the REST API documentation.

 

Note:If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS Pro. To access a locator that is on a portal other than your active portal, you can authenticate using SignInToPortal.

Generate suggestions based on an incomplete user input string using a locator on disk.

import arcpy # Create a new Locator object from a locator on disk locator_path = r"C:\Locators\Atlanta.loc" locator = arcpy.geocoding.Locator(locator_path) # Generate suggestions from partial user input suggestion_candidates = locator.suggest("1670 w peach")

Generate suggestions based on an incomplete user input string using ArcGIS World Geocoding Service.

import arcpy # Create a new Locator object from the ArcGIS World Geocoding Service locator_path = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service" locator = arcpy.geocoding.Locator(locator_path) # Generate suggestions from partial user input suggestion_candidates = locator.suggest("1670 w peach")

Generate suggestions based on an incomplete user input string using a locator accessed through an AGS connection.

import arcpy # Create a new Locator object from a locator published to ArcGIS Server locator_path = r"C:\AGS Files\MyAGSConnectionFile.ags\Atlanta" locator = arcpy.geocoding.Locator(locator_path) # Generate suggestions from partial user input suggestion_candidates = locator.suggest("1670 w peach")

geocodeWithSuggest (suggestResult, forStorage, {preferredSearchLocation}, {countryCode}, {categories}, {locationType}, {outFields}, {maxResults}, {minScore}, {outputLanguageCode}, {preferredLabelValues}, {searchExtent})

Parameter   Explanation   Data Type  

suggestResult

 

The output from the suggest method. The suggestion result is a dictionary that contains text, magicKey, and isCollection keys and is used to locate an address or place.

To learn more about the keys included in the suggestion result dictionary objects, see the REST API documentation.

  Dictionary  

forStorage

 

Specifies whether the results will be stored. The default value is False, which indicates the results won't be stored, but they can be temporarily displayed on a map. If you store the results, in a database, for example, set this parameter to True.

This parameter only applies to geocoding requests made with E:\Data\Certification\Desktop104\Geocoding\redlands_shp_1061. For all other locators, the parameter is ignored.

Note: Applications are contractually prohibited from storing the results of geocoding operations using E:\Data\Certification\Desktop104\Geocoding\redlands_shp_1061 unless they make the request by passing the forStorage parameter with a value of True. For a locator using E:\Data\Certification\Desktop104\Geocoding\redlands_shp_1061 to be valid, you must sign in to ArcGIS Online with a valid organizational account. ArcGIS Online service credits are deducted from the organizational account for each geocode transaction that stores results.

  Boolean  

preferredSearchLocation

 

The origin point that will be used to prefer or boost geocoding candidates based on their proximity to the location. Candidates near the location are prioritized relative to those farther away.

  PointGeometry  

countryCode

 

A comma-delimited string of three-character country codes that limits geocoding results to the set of specified countries, which will improve the accuracy of geocoding in most cases. When no country is specified, geocoding with suggestions will be performed using all countries supported by the locator.

If you are using ArcGIS World Geocoding Service, see the list of supported countries.

  String  

categories

 

A comma-separated list of categories that limits the types of places the locator searches, eliminating false positive matches and potentially speeding up the search process. See the REST API web help for details about category filtering.

  String  

locationType

 

Specifies the preferred output geometry that will be used for PointAddress matches. If the preferred location does not exist in the data, the default location will be returned instead. This parameter only affects the geometry, not the attribute values.

rooftopAn address location such as rooftop location, parcel centroid, or front door will be used. This is the default.

streetA location close to the side of the street that can be used for vehicle routing will be used.

  String  

outFields

 

The list of fields that will be returned as part of the attributes in the result. This parameter supports a single field name or a comma-delimited string of field names (with no spaces). To return the default output fields, outFields does not need to be passed. Use an asterisk ("*") to return all available output fields with the result. The output fields are described in What's included in the geocoded results.

  String  

maxResults

 

The maximum number of locations that will be returned, up to the maximum number allowed by the locator. If no value is provided, all matching candidates up to the maximum specified by the maxCandidate property in the Locator properties will be returned.

  Integer  

minScore

 

Limits the candidates that are returned to those with a score above the value set for this parameter. Valid values are between 0 and 100.

  Integer  

outputLanguageCode

 

The language in which the geocode results will be returned. Since addresses and places in many countries are available in more than one language, this will ensure that results are returned in the expected language.

If you are using ArcGIS World Geocoding Service, see the list of supported countries for the language codes that are supported for those countries.

  String  

preferredLabelValues

 

Configures the output fields returned in a response from the locator by specifying the address component values that should be included in the output fields. The parameter supports a single value or a comma-delimited string of values as input. For more information about how this parameter works, see Additional tuning options.

Possible values include postalCity, localCity, matchedCity, primaryStreet, and matchedStreet.

Note:

Only one value for city labeling and one value for street labeling can be included.

  String  

searchExtent

 

An extent that limits the area that will be searched. All results that are returned outside of the specified extent will be excluded.

  Extent  

Return ValueData Type   Explanation  
List  

The output of the geocodeWithSuggest method is a list of dictionary objects. Each dictionary represents a single geocoding result. Each geocoding result contains information about the match address or location, geometry information including x- and y-coordinates, and additional attributes depending on the Locator object used and the outFields value specified.

 

Note:If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS Pro. To access a locator that is on a portal other than your active portal, you can authenticate using SignInToPortal.

Generate suggestions based on an incomplete user input string, and geocode with one of the suggestions generated as the output of that operation to find a location using a locator on disk.

import arcpy # Create a new Locator object from a locator on disk locator_path = r"C:\Locators\Atlanta.loc" locator = arcpy.geocoding.Locator(locator_path) # Generate suggestions from partial user input suggestion_candidates = locator.suggest("1670 w peach") # Geocode using one of the suggestions generated as the output of the suggest # operation geocoding_candidates = locator.geocodeWithSuggest(suggestion_candidates[0], False)

Generate suggestions based on an incomplete user input string, and geocode with one of the suggestions generated as the output of that operation to find a location using ArcGIS World Geocoding Service.

import arcpy # Create a new Locator object from the ArcGIS World Geocoding Service locator_path = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service" locator = arcpy.geocoding.Locator(locator_path) # Generate suggestions from partial user input suggestion_candidates = locator.suggest("1670 w peach") # Geocode using one of the suggestions generated as the output of the suggest # operation geocoding_candidates = locator.geocodeWithSuggest(suggestion_candidates[0], True)

Generate suggestions based on an incomplete user input string, and geocode with one of the suggestions generated as the output of that operation to find a location using a locator accessed through an AGS connection.

import arcpy # Create a new Locator object from a locator published to ArcGIS Server locator_path = r"C:\AGS Files\MyAGSConnectionFile.ags\Atlanta" locator = arcpy.geocoding.Locator(locator_path) # Generate suggestions from partial user input suggestion_candidates = locator.suggest("1670 w peach") # Geocode using one of the suggestions generated as the output of the suggest # operation geocoding_candidates = locator.geocodeWithSuggest(suggestion_candidates[0], False)

updateLocator ()

Update a property of a locator on disk, and persist changes.

import arcpy # Create a new Locator object from a locator on disk locator_path = r"C:\Locators\Atlanta.loc" locator = arcpy.geocoding.Locator(locator_path) # Update the minimum match score property on the locator locator.minMatchScore = 95 # Persist changes to the .loc file locator.updateLocator()

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-10-14 04:10 最后登录:2025-10-14 04:10
栏目列表
推荐内容