Assign by Closest Stores Location (Business Analyst)
摘要
Assigns customers to stores by closest location using a straight-line distance method.
用法
-
You cannot undo the assignment of customers to stores in an existing field.
-
Customers are assigned to the closest store location.
-
Assignments are based on a straight-line Euclidean distance calculation.
-
Use the Assign By Trade Area tool if you do not want to assign customers using a straight-line distance. The Assign By Trade Area tool can be used with drive-time polygons.
-
If a customer is at an equal distance from two or more stores, the customer will be assigned to the first store in the attribute table.
语法
参数 | 说明 | 数据类型 |
InputFeatureLayer |
The store layer to which to assign customers. | Feature Layer |
IdField |
The unique identifier of each store. | Field |
CustomerLayer |
The customer layer used to make the customer assignments to each store. | Feature Layer |
LinkField |
The field that will be populated with the associated store ID. | Field |
UseSelectedFeatures (可选) |
Customers are assigned by selected features of the customer layer.
| Boolean |
WayToDefineLinkField (可选) |
Selects an existing store ID field or creates a new field.
| Boolean |
CreateNewFeatureClass (可选) |
Generates a new feature class based on the existing layer or uses the existing layer.
| Boolean |
OutputFeatureClass (可选) |
The feature class that will contain the assigned features. | Feature Class |
代码实例
# Name: AssignCustomersByLocation.py
# Description: Assigns customers in the San Francisco area to their designated stores by closest location using a straight-line distance metho
# Author: Esri
# Import system modules
import arview
import arcpy
arcpy.ImportToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.2\Business Analyst\ArcToolbox\Toolboxes\Business Analyst Tools.tbx")
try:
# Acquire extension license
arcpy.CheckOutExtension("Business")
# Defines the parameters for the Assign by Closest Stores Location tool
StorePath = "C:/temp/sf_stores.shp"
CustPath = "C:/temp/sf_cust.shp"
StoreId = "STORE_ID"
StoreLink = "STORE_ID"
# Assigns by Closest Stores Location
arcpy.AssignCustomersByLocation_ba(StorePath, StoreId, CustPath, StoreLink, "false")
# Release extension license
arcpy.CheckInExtension("Business")
except:
print arcpy.GetMessages(2)