當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python ArcGIS find_similar_locations用法及代碼示例

本文簡要介紹 python 語言中 arcgis.geoanalytics.find_locations.find_similar_locations 的用法。

用法:

arcgis.geoanalytics.find_locations.find_similar_locations(input_layer, search_layer, analysis_fields, most_or_least_similar='MostSimilar', match_method='AttributeValues', number_of_results=10, append_fields=None, output_name=None, gis=None, context=None, future=False, return_tuple=False)

返回:

  • 如果 return_tupleTrue ,具有以下鍵的命名元組:

  • 如果return_tuple is ``False` FeatureLayer

find_similar_locations.png

find_similar_locations 任務測量候選位置與一個或多個參考位置的相似性。

根據您指定的標準,find_similar_locations 可以回答以下問題:

  • 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 input_layer parameter), the candidate locations (the search_layer parameter), and the fields representing the criteria you want to match. For example, the input_layer might be a layer containing your top performing stores or the villages hardest hit by the disease. The search_layer 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 find_similar_locations task will rank all of the candidate locations by how closely they match your reference locations across all of the fields you have selected.

Parameter

Description

input_layer

必需的層。 input_layer 包含一個或多個參考位置,search_layer 中的特征將根據這些參考位置進行相似性評估。例如,input_layer 可能包含您表現最好的商店或受疾病影響最嚴重的村莊。請參閱特征輸入。

input_layersearch_layer 是同一個要素服務的情況並不少見。例如,要素服務包含所有商店的位置,其中一個是您表現最好的商店。如果您想將其餘商店從最相似到最不相似進行排名,您可以為 input_layersearch_layer 提供過濾器。 input_layer 上的過濾器將選擇表現最佳的商店,而search_layer 上的過濾器將選擇除表現最佳的商店之外的所有商店。您可以使用可選的過濾器參數來指定參考位置。

如果有多個參考位置,則相似性將基於您在 analysis_fields 參數中指定的字段的平均值。例如,如果有兩個參考位置並且您對匹配人口感興趣,則該任務將在 search_layer 中查找人口最接近兩個參考位置的平均人口的候選位置。例如,如果參考位置的值是 100 和 102,則該任務將尋找人口接近 101 的候選位置。因此,您將希望將字段用於具有相似值的參考位置字段。例如,如果一個參考位置的人口值為 100,而另一個為 100,000,則該工具將尋找人口值接近這兩個值的平均值的候選位置:50,050。請注意,這個平均值與任何一個參考位置的人口都不同。

search_layer

必需的層。包含將根據參考位置評估的候選位置的圖層。請參閱特征輸入。

analysis_fields

必需的字符串。其值用於確定相似性的字段列表。它們必須是數字字段,並且這些字段必須同時存在於 input_layersearch_layer 上。根據所選的match_method,任務將根據字段的值或配置文件查找最相似的特征。

most_or_least_similar

可選字符串。您想要返回的函數。您可以搜索與 input_layer 最相似或最不相似的特征,或者同時搜索最相似和最不相似的特征。

選擇清單:

  • MostSimilar

  • LeastSimilar

  • Both

默認值為 MostSimilar

match_method

可選字符串。您選擇的方法決定了如何確定匹配。

選擇清單:

  • AttributeValues - uses the squared differences of standardized values.

  • AttributeProfiles - uses cosine similarity mathematics to compare the profile of standardized values. Using AttributeProfiles requires the use of at least two analysis fields.

默認值為 AttributeValues

number_of_results

可選整數。排名候選位置的數量輸出到 similar_result_layer 。如果未設置number_of_results,則返回 10 個位置。結果的最大數量為 10000。

默認值為 10。

append_fields

可選字符串。 (可選)將字段從您的搜索圖層添加到您的數據。默認情況下,將附加搜索圖層中的所有字段。

output_name

可選字符串。該任務將創建結果的要素服務。您定義服務的名稱。

gis

運行此工具的可選 GIS 。如果未指定,則使用活動 GIS。

context

可選字典。 context 參數包含影響任務執行的其他設置。對於此任務,有四個設置:

  • extent - A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.

  • processSR - The features will be projected into this coordinate system for analysis.

  • 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.

  • dataStore - Results will be saved to the specified data store. For ArcGIS Enterprise, the default is the spatiotemporal big data store.

future

可選布爾值。如果是 True ,將返回一個 future 對象,並且進程不會等待任務完成。

默認為 False ,表示等待結果。

return_tuple

可選布爾值。如果 True ,則返回具有多個輸出鍵的命名元組。

默認值為 False

例子:

# Usage Example: To find potential retail locations based on the current top locations and their attributes.

similar_location_result = find_similar_locations(input_layer=stores_layer,
                                                 search_layer=locations,
                                                 analysis_fields="median_income, population, nearest_competitor",
                                                 most_or_least_similar="MostSimilar",
                                                 match_method="AttributeValues",
                                                 number_of_results=50,
                                                 output_name="similar_locations")

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 arcgis.geoanalytics.find_locations.find_similar_locations。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。