Skip To Content
ArcGIS Developer
Dashboard

Find Similar Locations

Description

Find Similar Locations

The FindSimilarLocations operation measures the similarity of candidate locations to one or more reference locations.

Based on criteria you specify, FindSimilarLocations can answer questions such as the following:

  • Which of your stores are most similar to your top performers with regard to customer profiles?
  • Based on characteristics of villages hardest hit by the disease, which other villages are high risk?

To answer questions such as these, you provide the reference locations (the inputLayer parameter), the candidate location (the searchLayer parameter), and the fields representing the criteria you want to match. For example, the inputLayer might be a layer containing your top performing stores or the villages hardest hit by the disease. The searchLayer contains your candidate locations to search. This might be all of your stores or all other villages. Finally, you supply a list of fields to use for measuring similarity. The FindSimilarLocations operation will rank all of the candidate locations by how closely they match your reference locations across all of the fields you have selected.

Request parameters

ParameterDetails
inputLayer

(Required)

The inputLayer contains one or more reference locations against which features in the searchLayer will be evaluated for similarity. For example, the inputLayer might contain your top performing stores or the villages hardest hit by a disease. For more information on inputLayer and searchLayer, see below.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST Examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"inputLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}
searchLayer

(Required)

The layer containing candidate locations that will be evaluated against the reference locations. For more information on inputLayer and searchLayer, see below.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST Examples

//REST web example
{"url":"https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"searchLayer": {"url":"https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}
analysisFields

(Required)

A list of fields whose values are used to determine similarity. They must be numeric fields, and the fields must exist on both the inputLayer and the searchLayer. Depending on the matchMethod selected, the task will find features that are most similar based on values or profiles of the fields.

REST Examples

//REST web example
CrimeRate, Beat

//REST scripting example
"analysisFields": "CrimeRate, Beat"
mostOrLeastSimilar

(Required)

The features you want to be returned. You can search for features that are either most similar or least similar to the inputLayer, or search both the most and least similar.

Values: MostSimilar | LeastSimilar | Both

REST Examples

//REST web example
LeastSimilar

//REST scripting example
"mostOrLeastSimilar": "MostSimilar"
matchMethod

(Required)

The method that specifies how matching is determined. The AttributeValues method uses the squared differences of standardized values. This is the default. The AttributeProfiles method uses cosine similarity mathematics to compare the profile of standardized values. Using AttributeProfiles requires the use of at least two analysis fields.

Values: AttributeValues | AttributeProfiles

REST Examples

//REST web example
AttributeValues

//REST scripting example
"matchMethod": "AttributeProfiles"
numberOfResults

(Required)

The number of ranked candidate locations output to similarResultLayer. If numberOfResults is not set, the 10 locations will be returned. The maximum number of results is 10000.

REST Examples

//REST web example
15

//REST scripting example
"numberOfResults": 15
appendFields

(Optional)

Add fields to your data from your search layer. By default, all fields from the search layer are appended.

REST Examples

//REST web example
ID Number

//REST scripting example
"appendFields": "ID Number"
outputName

(Required)

The task will create a feature service of the results. You define the name of the service.

REST Examples

//REST web example
myOutput

//REST scripting example
"outputName": "myOutput"
context

(Optional)

The context parameter contains additional settings that affect task execution. For this task, there are four settings:

  • Extent (extent)—A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.
  • Processing spatial reference (processSR)—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR)—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore)—Results will be saved to the specified data store. The default is the spatiotemporal big data store.

Syntax:
{
"extent" : {extent},
"processSR" : {spatial reference},
"outSR" : {spatial reference},
"dataStore":{data store}
}

f

The response format. The default response format is html.

Values: html | json

Notes on inputLayer and searchLayer

It is not uncommon for inputLayer and searchLayer to be the same feature service. For example, the feature service contains locations of all stores, one of which is your top performing store. If you want to rank the remaining stores from most to least similar to your top performing store, you can provide a filter for both inputLayer and searchLayer. The filter on inputLayer would select the top performing store, while the filter on searchLayer would select all stores except for the top performing store. You can use the optional filter parameter to specify reference locations.

If there is more than one reference location, similarity will be based on averages for the fields you specify in the analysisFields parameter. For example, if there are two reference locations and you are interested in matching population, the task will look for candidate locations in searchLayer with populations that are most like the average population for both reference locations. If the values for the reference locations are 100 and 102, for example, the task will look for candidate locations with populations near 101. Consequently, you will want to use fields for the reference locations fields that have similar values. If, for example, the population values for one reference location is 100 and the other is 100,000, the tool will look for candidate locations with population values near the average of those two values: 50,050. Notice that this averaged value is nothing like the population for either of the reference locations.

Example usage

Below is a sample request URL for FindSimilarLocations:

https://webadaptor.domain.com/server/rest/services/System/GeoAnalyticsTools/GPServer/FindHotSpots/submitJob?inputLayer={"url":"https://webadaptor.domain.com/server/rest/services/Hurricane/hurricaneTrack/0"}&searchLayer={"url":"https://webadaptor.domain.com/server/rest/services/Hosted/tornadoTrack/0"}&analysisFields=shelterLocations, shelterCapacity&mostOrLeastSimilar=MostSimilar&matchMethod=AttributeValues&numberOfResults=20&appendFields=&outputName=myOutput&context={"extent":{"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,"spatialReference":{"wkid":4326}}}&f=json

Response

When you submit a request, the service assigns a unique job ID for the transaction.

Syntax:
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically check the status of the job and messages as described in Check job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<analysis-url>/FindSimilarLocations/jobs/<jobId>

Accessing results

When the status of the job request is esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

https://<anaylsis-url>/FindSimilarLocations/jobs/<jobId>/results/<result type>?token=<your token>&f=json

ResponseDescription
output

Contains features from the inputLayer and the searchLayer. The number of features from the searchLayer is based on the value of the numberOfResults parameter. Fields added to outputName include all the fields from the searchLayer and the following:

  • location_type—A string denoting if the feature was an input reference location or a search location.
  • simrank—The similarity rank. Contains the rank for search locations, where 1 equals the candidate location most similar to the reference locations. Contains zero for reference locations.
  • dissimrank—The dissimilarity rank. Contains the rank for search locations, where -1 equals the candidate location most dissimilar to the reference locations. Contains zero for reference locations.
  • simindex—Quantifies how similar a candidate is compared to the reference locations. If a candidate location matches a reference location exactly, the value is zero. The larger the value, the more dissimilar a candidate is from the reference locations.
  • cosimindex—Quantifies how similar a candidate's profile is compared to the reference location's profile. If the profile of a candidate location matches the profile of a reference location exactly, the value is zero. The larger the value, the more dissimilar a candidate is from the reference locations.
  • labelrank—Used for labelling and rendering the outputs. The higher the values, the more similar; the lower the values, the more dissimilar. Values of 0 represent the reference locations. This value was introduced at ArcGIS Enterprise 10.6.1.
  • reference_id— A unique ID value for reference features. Search features are given a null value.
  • search_id— A unique ID value for search value features. Reference features are given a null value. This value was introduced at ArcGIS Enterprise 10.6.1.
{"url": "https://<analysis-url>/FindSimilarLocations/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.

processInfo

At 10.6.1 or later the processInfo parameter contains strings that summarize the Find Similar Locations result. These strings are used for reporting by the Find Similar Locations tool found in the map viewer. You can create your own custom reports for your application using these strings. There are four parts in the returned json:

  • messageCode—The serial number for each unique message.
  • message—Text that may or may not contain parameters (in ${paramsName} format) that need to be replaced by values.
  • params—A dictionary of the keys and values to be inserted into the ${paramsName} parameter in the message.
  • style—The formatting of the report produced by the Find Similar Locations tool in the map viewer.

{
  "messageCode" : "SS_84507",
  "message" : ["Attribute", "Min", "Max", "SD", "Mean","Input"],
  "params" : {},
  "style" : "<table><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr>"
}