arcpy.management.MakeAggregationQueryLayer(target_feature_class, target_join_field, related_table, related_join_field, out_layer, {statistics}, {parameter_definitions}, {oid_fields}, {shape_type}, {srid}, {spatial_reference}, {m_values}, {z_values}, {extent})
|
名称
|
说明
|
数据类型
|
|
target_feature_class
|
来自企业级地理数据库的要素类或空间表。
|
Feature Class
|
|
target_join_field
|
连接所依据的目标要素类中的字段。
|
Field
|
|
related_table
|
包含用于计算统计数据的字段的输入表。 统计数据连接到 out_layer 值。
|
Table; Feature Class
|
|
related_join_field
|
汇总表中的字段,其中包含连接所依据的值。 还会根据此字段单独为每个唯一属性值计算聚合或汇总统计数据。
|
Field
|
|
out_layer
|
将要创建的查询图层的输出名称。
|
Feature Layer
|
|
statistics
[[statistic_type, field],...]
(可选)
|
指定包含用于计算指定统计数据的属性值的一个或多个数值字段。 可以指定多项统计和字段组合。 空值将被排除在所有统计计算之外。
输出图层将包括一个 ROW_COUNT 字段,显示 related_join_field 值的每个唯一值的总数(或频数)。 ROW_COUNT 字段和 COUNT 统计类型的区别在于 ROW_COUNT 包括空值,而 COUNT 不包括空值。
值表列:
|
Value Table
|
|
parameter_definitions
[[parameter_def_type, name, alias, field_or_expression, data_type, start_value, end_value, operator, default_value, operator_for_next_parameter],...]
(可选)
|
为标准或条件指定一个或多个查询参数,并在计算聚合结果时使用与这些条件相匹配的记录。 查询参数类似于 SQL 语句的变量,进行查询时即会定义该变量的值。 这样,您便可以动态地更改输出图层的查询过滤器。 您可以将参数视为 SQL where 子句中的谓词或条件。 例如,Country_Name = 'Nigeria' 在 SQL where 子句中称为谓词,其中 = 是比较运算符,Country_Name 是左侧的字段名称,'Nigeria' 是右侧的值。 当您定义多个参数时,必须在这些参数之间指定一个逻辑运算符(如 AND、OR 等)。
了解有关在查询图层中定义参数的详细信息
如果未进行指定,则相关表中的所有记录都将用于计算聚合或汇总结果。
两种参数定义类型如下所示:
值表列:
Parameter Type—Specifies the parameter type.
Name—The name of the parameter, which is similar to a variable name. A name cannot contain spaces or special characters. Once the output query layer is created and the layer source SQL statement is checked, this name in the SQL statement that defines the output query layer source will be prefixed with either ::r: (for range parameter) or :: (for discrete parameter).
Alias—The alias for the parameter name. The alias can include spaces and special characters.
Field or Expression—A field name or a valid SQL expression that will be used in the left side of a predicate or condition in a where clause.
Data type—The data type of the field or expression specified in the Field or Expression column. When using a range parameter type, the data type cannot be string.
DATE—The data type of the field or expression will be Date (date time).
STRING—The data type of the field or expression will be String (text).
INTEGER—The data type of the field or expression will be Integer (whole numbers).
DOUBLE—The data type of the field or expression will be Double (fractional numbers).
Start Value—The default start value for the range parameter type. This is the value that will be used when the time or range slider is not enabled. When the start value and end value column values are omitted and the time or range slider is disabled, all records from the related table will be used to compute aggregated results. This value is ignored when using a discrete parameter type.
End Value—The default end value for the range parameter. This is the value that will be used when the time or range slider is not enabled. When the start value and end value column values are omitted and the time or range slider is disabled, all records from the related table will be used to compute aggregated results. This value is ignored when using a discrete parameter type.
Operator for Discrete Parameters—The comparison operator that will be used between the Field or Expression column value and a value in an SQL predicate or condition.
NONE—Use this option when using a range parameter type.
EQUAL TO—Compare the equality of a field or expression to a value.
NOT EQUAL TO—Test whether a field or expression is not equal to a value.
GREATER THAN—Test whether a field or expression is higher than a value.
LESS THAN—Test whether a field or expression is lower than a value.
INCLUDE VALUES—Determine whether a value from a field or expression matches any value in a list.
Default Discrete Parameters—When using a discrete parameter type, you must provide a default value. When the operator is include values, you can provide multiple values separated by commas, for example VANDALISM,BURGLARY/THEFT.
Operator for Next Parameters—The logical operator between this operator and the next one. This column is only applicable when you have more than one parameter definition.
NONE—Use this option when there are no more parameters
AND—Combine two conditions and select a record if both conditions are true.
OR—Combine two conditions and select a record if at least one condition is true.
|
Value Table
|
|
oid_fields
[oid_fields,...]
(可选)
|
唯一标识符字段 将用于唯一标识表中各行的字段。
|
String
|
|
shape_type
(可选)
|
指定查询图层的形状类型。 在输出查询图层中只会使用查询结果集中与指定形状类型匹配的那些记录。 默认情况下,将使用结果集中第一条记录的 shape 类型。 如果查询结果集未返回几何字段,则忽略此参数。
|
String
|
|
srid
(可选)
|
返回几何查询的空间参考标识符 (SRID) 值。 在输出查询图层中只会使用查询结果集中与指定 SRID 值匹配的那些记录。 默认情况下,将使用结果集中第一条记录的 SRID 值。 如果查询结果集未返回几何字段,则忽略此参数。
|
String
|
|
spatial_reference
(可选)
|
输出查询图层将使用的坐标系。 默认情况下,将使用结果集中第一条记录的空间参考。 如果查询结果集未返回几何字段,则忽略此参数。
|
Spatial Reference
|
|
m_values
(可选)
|
指定输出图层是否包括线性测量(m 值)。
|
Boolean
|
|
z_values
(可选)
|
指定输出图层是否将包括高程值(z 值)。
|
Boolean
|
|
extent
(可选)
|
指定图层范围。 范围必须包括表中的所有要素。
|
Extent
|
代码示例
MakeAggregationQueryLayer 示例 1(Python 窗口)
以下 Python 窗口脚本演示了如何通过点要素类计算每个区的犯罪总数,并将结果连接到警务区要素类。
import arcpy
arcpy.env.workspace = "C:/data/localhost.sde"
arcpy.management.MakeAggregationQueryLayer(
"PoliceDistricts", "district", "Crime_locations", "PdDistrict", "SF_Crimes")
MakeAggregationQueryLayer 示例 2(Python 窗口)
以下 Python 窗口脚本演示了如何通过点要素类计算每个区和每种犯罪类型的犯罪总数,并将结果连接到警务区要素类。
import arcpy
arcpy.env.workspace = "C:/data/localhost.sde"
arcpy.management.MakeAggregationQueryLayer(
"PoliceDistricts", "district", "Crime_locations", "PdDistrict", "SF_Crimes",
None,
"DISCRETE crime_type # Category STRING # # 'INCLUDE VALUES' 'VANDALISM, BURGLARY/THEFT' NONE")
MakeAggregationQueryLayer 示例 3(Python 窗口)
以下 Python 窗口脚本演示了如何通过时间序列表计算总降雨量和平均降雨量,并将结果连接到水站要素类。
import arcpy
arcpy.env.workspace = "C:/data/localhost.sde"
arcpy.management.MakeAggregationQueryLayer(
"weather_stations", "station_id", "observed_rainfall", "station_id",
"Total_Rainfall", [["SUM", "rainfall_inch"], ["MIN", "rainfall_inch"]])
MakeAggregationQueryLayer 示例 4(Python 窗口)
以下 Python 窗口脚本演示了如何通过时间序列表针对任意时间窗计算总降雨量和平均降雨量,并将结果连接到水站要素类。
import arcpy
arcpy.env.workspace = "C:/data/localhost.sde"
arcpy.management.MakeAggregationQueryLayer(
"weather_stations", "station_id", "observed_rainfall", "station_id",
"Total_Rainfall", [["SUM", "rainfall_inch"], ["MIN", "rainfall_inch"]],
"RANGE TimeVar # collection_date DATE 1/1/2020 12/1/2020 NONE # NONE")