本文簡要介紹 python 語言中 arcgis.features.analysis.join_features
的用法。
用法:
arcgis.features.analysis.join_features(target_layer, join_layer, spatial_relationship=None, spatial_relationship_distance=None, spatial_relationship_distance_units=None, attribute_relationship=None, join_operation='JoinOneToOne', summary_fields=None, output_name=None, context=None, gis=None, estimate=False, future=False, join_type='INNER', records_to_match=None)
返回:
result_layer:如果指定了output_name,則為
FeatureLayer
,否則為FeatureCollection
。
join_features
方法適用於兩個圖層,並根據空間和屬性關係將屬性從一個要素連接到另一個要素。Parameter
Description
target_layer
必需的層。將具有來自
join_layer
的屬性附加到其表的點、線、多邊形或表層。請參閱特征輸入。join_layer
必需的層。將連接到
target_layer
的點、線、多邊形或表格圖層。請參閱特征輸入。spatial_relationship
如果不是表格圖層,則為必需字符串。定義用於空間連接要素的空間關係。
選擇列表:[‘identicalto’, ‘intersects’, ‘completelycontains’, ‘completelywithin’, ‘withindistance’]
spatial_relationship_distance
可選浮點數。用於搜索距離的浮點值,以確定目標要素是否在某個範圍內或附近
(如果
spatial_relationship
在距離內,則為必需)連接要素的指定距離。這僅適用於在選定的
spatial_relationship
的距離內。您隻能輸入一個距離值。距離值的單位由spatial_relationship_distance_units
參數提供。spatial_relationship_distance_units
可選字符串。與
spatial_relationship_distance
中指定的距離值一起使用的線性單位。(如果
spatial_relationship
在距離內,則為必需)選擇列表:['Miles'、'Yards'、'Feet'、'NauticalMiles'、'Meters'、'Kilometers']
默認為“裏程”。
attribute_relationship
可選的字典列表。定義用於連接要素的屬性關係。當連接圖層中的字段值等於目標圖層中的字段值時,要素匹配。
join_operation
可選字符串。表示將應用的聯接類型的字符串
選擇列表:[‘JoinOneToOne’, ‘JoinOneToMany’]
JoinOneToOne
- 如果發現多個連接要素與單個目標要素具有相同的關係,則將使用指定的匯總統計信息聚合多個連接要素的屬性。例如,如果在兩個單獨的麵連接要素中找到點目標要素,則兩個麵的屬性將在傳輸到輸出點要素類之前進行聚合。如果一個麵的屬性值為 3,另一個麵的屬性值為 7,並且選擇了 SummaryField 總和,則輸出要素類中的聚合值將為 10。始終會計算一個 Count 字段,其中對於指定的要素數量,值為 2。這是默認設置。JoinOneToMany
- 如果發現多個連接要素與單個目標要素具有相同的關係,則輸出要素類將包含目標要素的多個副本(記錄)。例如,如果在兩個單獨的多邊形連接要素中找到一個點目標要素,則輸出要素類將包含目標要素的兩個副本:一個記錄具有第一個多邊形的屬性,另一個記錄具有第二個多邊形的屬性多邊形。沒有使用此方法計算的匯總統計數據。
summary_fields
可選的字典列表。要計算的字段名稱和統計匯總類型的列表。請注意,默認情況下始終返回計數。
fieldName 是在輸入連接層中找到的數字字段之一的名稱。
statisticType 是以下之一:
SUM
- 將每個多邊形中所有點的總值相加MEAN
- 計算每個多邊形中所有點的平均值MIN
- 找到每個多邊形中所有點的最小值MAX
- 找到每個多邊形中所有點的最大值STDDEV
- 找出每個多邊形中所有點的標準差
output_name
可選字符串或
FeatureLayer
。現有要素圖層將導致新圖層附加到要素服務。如果 overwrite 在上下文中為 True,則新層將覆蓋現有層。如果未指示output_name,則創建新的FeatureCollection
。context
可選字典。處理範圍和輸出空間參考等附加設置。對於join_features,有三個設置。
extent
- 定義分析區域的邊界框。僅分析input_layer 中與邊界框相交的那些特征。outSR
- 輸出要素將投影到wkid
引用的輸出空間參考中。overwrite
- 如果為 True,則 output_name 中的要素層將被新要素層覆蓋。適用於 ArcGIS Online 或 Enterprise 10.9.1+# Example Usage context = {"extent": {"xmin": 3164569.408035, "ymin": -9187921.892449, "xmax": 3174104.927313, "ymax": -9175500.875353, "spatialReference":{"wkid":102100,"latestWkid":3857}}, "outSR": {"wkid": 3857}, "overwrite": True}
estimate
可選的布爾值。如果為 True,將返回運行該操作的積分數。
future
可選布爾值。如果為 True,則將返回 future 對象,並且進程不會等待任務完成。默認為False,表示等待結果。
join_type
可選字符串。確定對數據集執行的連接類型。允許的值為 INNER 或 LEFT。
records_to_match
可選字典。定義兩個特征如何連接。例子:
{“groupByFields”:””,“orderByFields”:”objectid ASC”,“topCount”:1}例子:
# USAGE EXAMPLE: To summarize traffic accidents within each parcel using spatial relationship. accident_count_in_each_parcel = join_features(target_layer=parcel_lyr, join_layer=traffic_accidents_lyr, spatial_relationship='intersects', summary_fields=[{"statisticType": "Mean", "onStatisticField": "Population"}, output_name='join features', context={"extent":{"xmin":-9375809.87305117,"ymin":4031882.3806860778,"xmax":-9370182.196843527,"ymax":4034872.9794178144,"spatialReference":{"wkid":102100,"latestWkid":3857}}}, )
相關用法
- Python ArcGIS power用法及代碼示例
- Python ArcGIS APIKeyManager.get用法及代碼示例
- Python ArcGIS KnowledgeGraph.named_object_type_delete用法及代碼示例
- Python ArcGIS ContentManager.unshare_items用法及代碼示例
- Python ArcGIS ImageryLayer.thumbnail用法及代碼示例
- Python ArcGIS FormFieldElement用法及代碼示例
- Python ArcGIS Geometry.true_centroid用法及代碼示例
- Python ArcGIS Site.delete用法及代碼示例
- Python ArcGIS GeoAccessor.bbox用法及代碼示例
- Python arcgis.apps.hub.Initiative.update用法及代碼示例
- Python ArcGIS generate_service_areas用法及代碼示例
- Python ArcGIS build_overview用法及代碼示例
- Python ArcGIS RunInterval用法及代碼示例
- Python ArcGIS describe_dataset用法及代碼示例
- Python ArcGIS acos用法及代碼示例
- Python ArcGIS Item.publish用法及代碼示例
- Python ArcGIS MapImageLayer.find用法及代碼示例
- Python ArcGIS Group.get_members用法及代碼示例
- Python ArcGIS Geometry.last_point用法及代碼示例
- Python ArcGIS Worker用法及代碼示例
- Python ArcGIS ContentManager.delete_folder用法及代碼示例
- Python ArcGIS train_classifier用法及代碼示例
- Python ArcGIS APIKeyManager.create用法及代碼示例
- Python ArcGIS negate用法及代碼示例
- Python ArcGIS add_image用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 arcgis.features.analysis.join_features。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。