必须在门户上具有发布者或管理员权限才能运行此工具。 如果您是具有自定义角色的成员,请确保门户管理员已授予您发布托管 web 图层的权限。
用法
您可以对存储在单个字段中、分为多个字段或存储在单个字段和一个国家/地区字段中的地址进行地理编码。 单个输入字段可存储完整地址,例如,303 Peachtree St NE, Atlanta, GA 30308。 如果将常规美国地址的输入地址划分为 Address、City、State 和 ZIP 等多个字段,则系统支持多个字段。 也支持使用存储完整地址的单个输入字段(例如,303 Peachtree St NE, Atlanta, GA 30308)和一个存储与地址关联的国家/地区(例如 USA)的字段。
某些定位器支持多个输入地址字段,例如 Address、Address2 和 Address3。 在此情况下,可以将地址组件分为多个字段,然后在进行地理编码时将地址字段连接在一起。 例如,跨三个字段的 100、Main st 和 Apt 140,或者跨两个字段的 100 Main st 和 Apt 140,在进行地理编码时,都将成为 100 Main st Apt 140。
此工具禁用 ArcGIS World Geocoding Service。 如果想要使用 ArcGIS World Geocoding Service,请使用地理编码地址工具。
Address Locator
地址字段映射
定位器使用的地址字段会映射到输入地址表中的字段。 如果完整地址储存在输入表的一个字段中,例如 303 Peachtree St NE, Atlanta, GA 30308,请指定 单个字段。 如果将常规美国地址的地址输入划分为 Address、City、State 和 ZIP 等 多个字段,则需指定多个字段。 如果将完整地址和国家/地区拆分为多个字段,例如,303 Peachtree St NE, Atlanta, GA 30308 和 USA 被拆分为 Address 和 Country,则需指定 单个字段和国家/地区字段。
某些定位器支持多个输入地址字段,例如 Address、Address2 和 Address3。 在此情况下,可以将地址组件分为多个字段,然后在进行地理编码时将地址字段连接在一起。 例如,跨三个字段的 100、Main St 和 Apt 140,或者跨两个字段的 100 Main St 和 Apt 140,在进行地理编码时,都将成为 100 Main St Apt 140。
您可以可以指定单个输入字段以存储完整地址,例如,303 Peachtree St NE, Atlanta, GA 30308。 如果常规美国地址的输入地址划分为 Address、City、State 和 ZIP 等多个字段,则可以指定多个字段。 您也可以指定存储完整地址(例如 303 Peachtree St NE, Atlanta, GA 30308)的单个输入字段和存储与地址关联的国家(例如 USA)的字段。
某些定位器支持多个输入地址字段,例如 Address、Address2 和 Address3。 在此情况下,可以将地址组件分为多个字段,然后在进行地理编码时将地址字段连接在一起。 例如,跨三个字段的 100、Main St 和 Apt 140,或者跨两个字段的 100 Main St 和 Apt 140,在进行地理编码时,都将成为 100 Main St Apt 140。
如果您正在使用您的门户上的定位器,请确保您已登录系统并在 ArcGIS Pro 中将其设置为活动门户。 要访问除活动门户之外的门户上的定位器,请使用 SignInToPortal 函数进行身份验证。
import arcpy
# Input is a hosted table
input_table = "https://<machine_name>/server/rest/services/Hosted/<item_name>/FeatureServer/<table_number>"
# This tool works with locators on your portal
in_locator = "https://<machine_name>/server/rest/services/<locator_name>/GeocodeServer/<locator_name>"
# The easiest way to generate a field mapping is to run the tool in ArcGIS
# Pro and right-click the green success ribbon and click "Copy Python command"
field_mapping = "'Street or Intersection' address VISIBLE NONE;'City or Placename' <None> VISIBLE NONE;State <None> VISIBLE NONE;'ZIP Code' zip VISIBLE NONE"
output_name = "geocoding_output"
# Optional geocoding parameters. Only some are supported depending on the
# in_locator that you use.
country = None
location_type = None
category = None
# The output is a hosted feature layer on your portal. To retrieve the
# output, go to your portal and look for a new item with the output_name that
# you entered.
arcpy.geocoding.GeocodeLocationsFromTable(input_table, in_locator,
field_mapping, output_name, country,
location_type, category)