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


Python ArcGIS summarize_within用法及代碼示例

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

用法:

arcgis.geoanalytics.summarize_data.summarize_within(summarized_layer, summary_polygons=None, bin_type=None, bin_size=None, bin_size_unit=None, standard_summary_fields=None, weighted_summary_fields=None, sum_shape=True, shape_units=None, group_by_field=None, minority_majority=False, percent_shape=False, output_name=None, gis=None, context=None, future=False)

返回:

FeatureLayer

summarize_within_geo.png

summarize_within 任務查找位於第一個輸入層區域邊界內的特征(和部分特征)。以下是示例:

  • Given a layer of watershed boundaries and a layer of land-use boundaries, calculate the total acreage of land-use type for each watershed.

  • Given a layer of parcels in a county and a layer of city boundaries, summarize the average value of vacant parcels within each city boundary.

  • Given a layer of counties and a layer of roads, summarize the total mileage of roads by road type within each county.

您可以將summarize_within 視為采用兩層並將它們堆疊在一起。其中一層 summary_polygons 必須是一個多邊形層,並想象這些多邊形邊界都是紅色的。另一層 summarized_layer 可以是任何要素類型 — 點、線或麵。將這些層堆疊在一起後,您向下查看堆棧並計算 summarized_layer 中落在具有紅色邊界 (summary_polygons) 的多邊形內的要素數量。不僅可以統計特征的數量,還可以計算summarized_layer中特征屬性的簡單統計,例如sum、mean、minimum、maximum等。

注意:

必須指定summary_polygonsbin_type

Parameter

Description

summarized_layer

必需的層。將為 summary_polygons 或 bin 中的每個麵匯總的點、線或麵要素。請參閱特征輸入。

summary_polygons

可選層。多邊形特征。將匯總 summarized_layer 中落在這些多邊形邊界內的要素或要素部分。您可以選擇在您提供的多邊形圖層內或在工具運行時生成的方形或六邊形 bin 內進行匯總。請參閱特征輸入。

bin_type(如果未指定summary_polygons,則為必需)

可選字符串。將生成的 bin 類型和summarized_layer 將匯總到。

選擇清單:

  • Hexagon

  • Square

注意:

如果選擇bin_type,則需要bin_sizebin_size_unit

注意:

使用SquareHexagon bin 進行分析需要投影坐標係。將圖層聚合到 bin 中時,輸入圖層或處理範圍 ( processSR ) 必須具有投影坐標係。如果未指定投影坐標係:

  • At 10.5.1, 10.6, and 10.6.1, the World Cylindrical Equal Area (WKID 54034) projection will be used.

  • At 10.7 or later, a projection will be picked based on the extent of the data.

bin_size(如果指定了bin_type,則為必需)

可選浮點數。 bin_type 類型的 bin 的距離。生成 bin 時,對於 Square,指定的數量和單位確定正方形的高度和長度,對於 Hexagon,指定的數量和單位確定平行邊之間的距離。

bin_size_unit(如果指定了bin_size,則為必需)

可選字符串。 summarized_layer 將匯總到的 bin 的線性距離單位。

選擇清單:

  • Feet

  • Yards

  • Miles

  • Meters

  • Kilometers

  • NauticalMiles

standard_summary_fields

可選的字典列表。您想要為 summary_polygonsbin_type 條柱中每個麵內的 summarized_layer 中的所有要素計算的字段名稱和統計摘要類型的列表。標準統計數據是使用 summary_polygons 內任何要素的整個屬性值計算的。

用法:[{"statisticType" : "<statistic type>", "onStatisticField" : "<field name>" }]

  • onStatisticField is the name of the field in the input point layer.

  • statisticType is one of the following

    • for numeric fields:

      • Count - Totals the number of features in each polygon.

      • Sum - Adds the total value of all the features in each polygon.

      • Mean - Calculates the average of all the features in each polygon.

      • Min - Finds the smallest value of all the features in each polygon.

      • Max - Finds the largest value of all the features in each polygon.

      • Range - Finds the difference between Min and Max.

      • Stddev - Finds the standard deviation of all the features in each polygon.

      • Var - Finds the variance of all the features in each polygon.

    • for string fields:

      • Count - Totals the number of strings for all the features in each polygon.

      • Any - Returns a sample string of a feature in each polygon.

weighted_summary_fields

可選的字典列表。您想要為 summary_polygonsbin_type 條柱中每個麵內的 summarized_layer 中的所有要素計算的字段名稱和統計摘要類型的列表。加權統計數據是使用 summary_polygons 內要素的地理加權屬性值計算的。比例統計的結果字段將用 p 表示。加權統計隻能應用於具有線或多邊形幾何形狀的summarized_layer

用法:[{"statisticType" : "<statistic type>", "onStatisticField" : "<field name>" }]

  • onStatisticField is the name of the field in the input point layer.

  • statisticType is one of the following:

    • for numeric fields:

      • Count - The count of each field multiplied by the proportion of the summarized layer within the polygons.

      • Sum - The sum of weighted of values in each field. Where the weight applied is the proportion of the summarized layer within the polygons.

      • Mean - The weighted mean of values in each field. Where the weight applied is the proportion of the summarized layer within the polygons.

      • Min - The minimum of weighted values in each field. Where the weight applied is the proportion of the summarized layer within the polygons.

      • Max - The maximum of weighted values in each field. Where the weight applied is the proportion of the summarized layer within the polygons.

      • Range - Finds the difference between Min and Max.

      • Stddev - The standard deviation of weighted values in each field. Where the weight applied is the proportion of the summarized layer within the polygons. (Added 10.9.1)

      • Var - The variance of weighted values in each field. Where the weight applied is the proportion of the summarized layer within the polygons. (Added 10.9.1)

sum_shape

可選的布爾值。一個布爾值,指示任務根據 summarized_layer 的形狀類型計算統計信息,例如 summary_polygons 中每個多邊形內 summarized_layer 的線的長度或多邊形的麵積。

默認值為 True

shape_units

可選字符串。用於計算 sum_shape 的單位。

值:

  • When summarized_layer contains polygons, Choice list: [‘Acres’, ‘Hectares’, ‘SquareMeters’, ‘SquareKilometers’, ‘SquareMiles’, ‘SquareYards’, ‘SquareFeet’].

  • When summarized_layer contains lines, Choice list: [‘Meters’, ‘Kilometers’, ‘Feet’, ‘Yards’, ‘Miles’]

group_by_field

可選字符串。這是 summarized_layer 函數的一個字段,可用於單獨計算每個唯一屬性值的統計信息。例如,假設 summarized_layer 說明城市邊界,而 summary_polgyons 要素是地塊。 ` 地塊圖層具有 Status 屬性,其值為 VACANTOCCUPIED` 。要計算城市邊界內空置和已占用地塊的總麵積,請使用 Status 作為 group_by_field 字段參數。

注意:

此參數在 ArcGIS Enterprise 10.6.1 及更高版本中可用。

當提供 group_by_field 字段時,服務將返回包含 groupBySummaryoutput 參數中的統計信息的表。

minority_majority

可選布爾值。僅當指定 group_by_field 時,此布爾參數才適用。如果為 true,則計算每個組字段的少數(最不主導)或多數(最主導)屬性值。 result_layer 中添加了兩個新字段,前綴為 Majority_ 和 Minority_。

注意:

此參數在 ArcGIS Enterprise 10.6.1 及更高版本中可用。

默認值為“假”。

percent_shape

可選布爾值。僅當指定 group_by_field 時,此布爾參數才適用。如果設置為 true,則為圖層多邊形內的每個總和計算每個唯一 group_by_field 值的百分比。默認為 false。

注意:

此參數在 ArcGIS Enterprise 10.6.1 及更高版本中可用。

默認值為 False

output_name

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

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.

gis

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

future

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

例子:

# Usage Example: To calculate the distance and average slope of bike lanes within each city district.

summarize_within_result = summarize_within(summary_polygons=districts,
                                           summarized_layer=bike_lanes,
                                           weighted_summary_fields=[{"statisticType" : "Average","onStatisticField" : "Slope"}],
                                           output_name="summary_of_bike_lanes")

相關用法


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