当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。