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


Python ArcGIS aggregate_points用法及代码示例


本文简要介绍 python 语言中 arcgis.geoanalytics.summarize_data.aggregate_points 的用法。

用法:

arcgis.geoanalytics.summarize_data.aggregate_points(point_layer, bin_type=None, bin_size=None, bin_size_unit=None, polygon_layer=None, time_step_interval=None, time_step_interval_unit=None, time_step_repeat_interval=None, time_step_repeat_interval_unit=None, time_step_reference=None, summary_fields=None, output_name=None, gis=None, future=False, context=None)

返回:

result_layer :将要素输出为 FeatureLayer

aggregate_points.png

aggregate_points 工具适用于一层点要素和一层区域。区域层可以是输入多边形层,也可以是运行任务时计算的正方形或六边形 bin。该工具首先确定哪些点位于每个指定区域内。在确定了这个point-in-area空间关系后,计算该区域内所有点的统计数据并分配给该区域。最基本的统计数据是该区域内的点数,但您也可以获得其他统计数据。

例如,假设您有咖啡店位置的点特征和县的区域特征,并且您想按县汇总咖啡销售。假设咖啡店有一个TOTAL_SALES属性,你可以得到每个县内所有TOTAL_SALES的总和,每个县内最小或最大TOTAL_SALES,或其他统计数据,如计数、范围、标准差和方差.

此工具还可以处理time-enabled 的数据。如果在输入点上启用了时间,则时间切片选项可用。时间切片允许您在查看特定时间切片的同时计算point-in 区域关系。例如,您可以查看每小时间隔,这将导致每小时的输出。

以时间为例,假设您有在咖啡店位置进行的每笔交易的点特征,并且没有区域图层。这些数据已经记录了一年多,每笔交易都有一个位置和一个时间戳。假设每笔交易都有一个TOTAL_SALES 属性,您可以获得感兴趣的空间和时间内所有 TOTAL SALES 的总和。如果这些交易是针对单个城市的,我们可以生成一公里网格的区域,并查看每周的时间片来总结时间和空间上的交易。

注意:

必须指定bin_typepolygon_layer。如果使用bin_type,则必须同时包含bin_sizebin_size_unit

Parameter

Description

point_layer

必填点 FeatureLayer 。将聚合到 polygon_layer 中的面或 bin_type 指定的箱中的点要素。请参阅特征输入。

bin_type

可选字符串。如果未提供polygon_layer,则为必需。

将生成的 bin 类型以及将聚合的点。

选择清单:

  • Square

  • Hexagon

默认值为 Square

注意:

如果未提供 polygon_layer,则为必需。

bin_size(如果使用bin_type,则为必需)

可选浮点数。 point_layer 将聚合到的 bin_type 的每个 bin 的维度。

  • if Square - the height and length of the sides

  • if Hexagon - the distance between parallel sides

bin_size_unit(如果使用bin_size,则为必需)

可选字符串。 bin_type 指定的 bin 的单位,point_layer 将聚合到其中。

选择清单:

  • Feet

  • Yards

  • Miles

  • Meters

  • Kilometers

  • NauticalMiles

对于bin_type
  • if Square - bin_size 边的高度和长度的单位

  • if Hexagon - 平行边之间bin_size 的单位

polygon_layer

可选多边形feature layer。输入点将聚合到的面要素(区域)。请参阅特征输入。

注意:

如果未提供 bin_type,则为必需。

time_step_interval

可选整数。一个数值,指定时间步长间隔的持续时间。此选项仅在输入点为 time-enabled 且代表时间瞬间时可用。

默认值为 None

time_step_interval_unit

可选字符串。指定时间步间隔单位的字符串。

注意:

仅当输入点为 time-enabled 且表示时间点时才可用。

选择清单:

  • Years

  • Months

  • Weeks

  • Days

  • Hours

  • Minutes

  • Seconds

  • Milliseconds

默认值为 None

time_step_repeat_interval

可选整数。一个数值,指定时间步重复发生的频率。仅当输入点为 time-enabled 且时间类型为即时时,此选项才可用。

time_step_repeat_interval_unit

可选字符串。指定步骤重复的时间单位的字符串。

注意:

仅当输入点为 time-enabled 且时间类型为 instant 时,此选项才可用。

选择清单:
  • Years

  • Months

  • Weeks

  • Days

  • Hours

  • Minutes

  • Seconds

  • Milliseconds

默认值为 None

time_step_reference

可选的日期时间。一个日期,指定将时间片对齐到的参考时间,以从纪元开始的毫秒数表示。默认值为 1970 年 1 月 1 日凌晨 12:00(纪元时间戳 0)。仅当输入点为 time-enabled 且时间类型为即时时,此选项才可用。

summary_fields

可选的字典列表。要为每个多边形或 bin 内的所有点计算的字段名称和统计汇总类型的列表。请注意,始终返回每个多边形内的点数。默认情况下,返回所有统计信息。

例子:[{"statisticType": "Count", "onStatisticField": "fieldName1"}, {"statisticType": "Any", "onStatisticField": "fieldName2"}]

  • 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 values of all the points in each polygon.

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

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

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

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

      • Range - Finds the difference between the Min and Max values.

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

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

    • for string fields:

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

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

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 ,表示等待结果。

例子:

# Usage Example: To aggregate number of 911 calls within 1 km summarized by Day count.

agg_result = aggregate_points(calls,
                              bin_size=1,
                              bin_size_unit='Kilometers',
                              time_step_interval=1,
                              time_step_interval_unit="Years",
                              summary_fields=[{"statisticType": "Count", "onStatisticField": "Day"}],
                              output_name='testaggregatepoints01')

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 arcgis.geoanalytics.summarize_data.aggregate_points。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。