B U S I N E S S A N A L Y S T 10.2 R E S T C U S T O M E R / S T O R E S E T U P T A S K
Assign Customers by Closest Store Endpoint
Assigns or reassigns customer features to stores using straight-line distance to the closest store feature location.
Availability: Business Analyst Server.
http://localhost:6080/arcgis/rest/services/DefaultMap/MapServer/exts/BAServer/AssignCustomersByClosestStore/execute
Specific Parameters
CustomerLinkField (required) |
The name of field in the Customers layer to be used for assignment customers with stores. Type string. |
Customers (required) |
The customer layer used to make the customers assignment to stores. Type PointLayer. |
Stores (required) |
The store layer to which to assign customers. Type PointLayer. |
AnalysisExtent (optional) |
Data extent to restrict the analysis. Type ExtentData. |
StoreIDField (optional) |
The attribute field name in the Stores layer which is associated with unique store/business IDs (typically store numbers for retail establishments with multiple locations). Type string. Default: "STORE_ID". |
UseThiessenPolygons (optional) |
An option specifying the use of Thiessen polygons. Type boolean. Default: false. |
Other Parameters
OutputType (required) |
Array of task output options. Options for this endpoint include rendering an output image (GetMapImage) and/or creating a feature layer for subsequent analysis (GetFeatureClass). Type array of TaskOutputType. |
ActiveDatasetID (optional) |
ID of the active dataset. Type string. Default: ID of the first available dataset. |
f (optional) |
Response format. Type string. Available formats: HTML, JSON, PJSON, XML. Default: HTML. |
IsFullErrorMessage (optional) |
Mode for composing error messages. Type boolean. Default: false. |
OutputAnalysisItem (optional) |
Configuration options for storing the output feature layer in the repository. This will enable viewing and working with the output result in subsequent tasks. Type esriFolderItem. |
OutputSpatialReference (optional) |
An option specifying the spatial reference to return the output feature layer in. Type SpatialReference. If this parameter is missing, the output record set will be returned in the default spatial reference. See Get Default Spatial Reference lookup operation to query the default spatial reference. |
RenderingParameters (optional) |
Configuration options for rendering output when GetMapImage option is specified in the OutputType parameter. Type RenderingParameters. |
ReturnGeometry (optional) |
An option specifying the presence of the shape attribute in the returned record set. Type boolean. Default: true. |
token |
Authentication token. This parameter is required if your Business Analyst Server is secured. Type string. |
Returns
Variable of type TaskResultOutput
Remarks
For most Business Analyst Server analyses you need to assign customers contained in the customer datasets either to stores or to trade areas. To create customer-derived trade areas around your customers or to create desire lines, your customer data must contain a field that associates each customer with a particular store. A number of analyses in Business Analyst Server require that your customer data has a store assignment field. If you do not have such a field, you can create one using the Assign Customers by Closest Store endpoint. This endpoint assigns customers to the closest store.
Two algorithms for closest store assignment are implemented: direct assignment and assignment based on the creation of Thiessen polygons. The first algorithm compares the straight-line distance from a customer to every store and selects a store with minimal distance from the customer. The last algorithm constructs Thiessen equal-competition polygons around stores and then assigns all customers to stores by their polygons.
The analysis can be restricted to an analysis extent if the AnalysisExtent parameter is specified.
Usage Tips
• 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.
• The UseThiessenPolygons option can essentially improve performance of the assignment if the number of customers is big enough.
• If a customer is at an equal distance from two or more stores, the customer will be assigned to any of these stores.
• Use the Assign Customers by Trade Area endpoint if you do not want to assign customers using a straight-line distance. This method can be used with drive-time polygons.
How Does it Work
This method assigns each customer the ID of the store that is closest, using a straight-line distance. The image below illustrates how these assignments are made. The image has two store locations (yellow and blue squares) and a set of customers (red triangles). In this simplified example, each of the customer points will inherit the store ID of the closest store location.
You cannot undo the assignment of customers to stores in an existing field. Be careful not to overwrite an existing field.
Example Usage
The example below assigns four customers to the nearest of three stores using the straight-line distance calculation algorithm.
{ "results": [ { "paramName":"OutputFeatureClass", "dataType":"GPFeatureRecordSetLayer", "value": { "geometryType":"esriGeometryPoint", "spatialReference": { "wkid":4326 }, "fieldAliases": { "OBJECTID":"Object ID", "Latitude":"Latitude", "Longitude":"Longitude", "STORE_ID":"STORE_ID", "NAME":"NAME", "DESCR":"DESCR", "STORE_ADDR":"STORE_ADDR", "NewStoreID":"NewStoreID" }, "fields": [ { "name":"OBJECTID", "type":"esriFieldTypeOID", "alias":"Object ID" }, ... { "name":"NewStoreID", "type":"esriFieldTypeString", "alias":"NewStoreID", "length":256 } ], "features": [ { "geometry": { "x":-117.24996, "y":32.74198, "spatialReference": { "wkid":4326 } }, "attributes": { "OBJECTID":1, "Latitude":32.74198, "Longitude":-117.24996, "STORE_ID":"5", "NAME":"jane_smith", "DESCR":"Jane Smith", "STORE_ADDR":"", "NewStoreID":"2" } }, ... { "geometry": { "x":-117.204533, "y":32.854672, "spatialReference": { "wkid":4326 } }, "attributes": { "OBJECTID":4, "Latitude":32.854672, "Longitude":-117.204533, "STORE_ID":"5", "NAME":"byron_jackson", "DESCR":"Byron Jackson", "STORE_ADDR":"", "NewStoreID":"1" } } ] } } ], "messages": [ ] }
NOTE: The response has been abbreviated where "..." is noted.
JSON Response Example Rendered with the ArcGIS API for JavaScript
See Also