RasterCollection

摘要

定义要包含在集合中的输入栅格和属性组,其中的集合将用于处理。

说明

RasterCollection 对象允许对一组栅格进行轻松排序和过滤,并准备一个集合以进行其他处理和分析。

RasterCollection 对象包括六个方法(maxminmedianmeanmajoritysum),以计算集合栅格中匹配波段上每个像素的统计信息。

例如,sum 方法将栅格项 1 波段 1 中的像素值与栅格项 2 波段 1 中的像素值相加,并返回波段 1 包含这些求和值的 Raster 对象。

RasterCollection 类的求和方法

语法

RasterCollection
 (rasters, {attribute_dict})
参数说明数据类型
rasters
[rasters,...]

输入栅格数据集。受支持的输入包括栅格列表、镶嵌数据集、云栅格格式的多维栅格、NetCDF 文件或图像服务。如果使用的是栅格数据集列表,则所有栅格必须具有相同的像元大小和空间参考。

List
attribute_dict

包含当输入为栅格列表时要添加到每个栅格的属性信息的 Python 字典。对于每个键值对,键是属性名称,而值是用于表示每个栅格的属性值的值列表。例如,要将名称字段添加到包含三个栅格的列表中,请使用 {"name": ["Landsat8_Jan", "Landsat8_Feb", "Landsat8_Mar"]}

(默认值为 None)

Dictionary

属性

属性说明数据类型
fields
(只读)

栅格集合中包含的字段名称列表。

String
count
(只读)

栅格集合中的项目总数。

Integer

方法概述

方法说明
filter ({where_clause}, {query_geometry_or_extent})

按属性或几何过滤栅格项目的集合,并返回仅包含满足过滤器的项目的栅格集合。如果未提供任何参数,则来自栅格集合的所有栅格项目将在新的栅格集合中返回。

filterByAttribute (field_name, operator, field_values)

按属性查询过滤栅格项目的集合,并返回仅包含满足查询的项目的栅格集合。

要根据时间字段查询栅格集合,请使用 filterByTime 方法。

filterByCalendarRange (calendar_field, start, {end}, time_field_name, date_time_format)

按日历字段范围过滤栅格项目的集合,并返回仅包含满足过滤器的项目的栅格集合。如果未提供任何参数,则来自栅格集合的所有栅格项目将在新的栅格集合中返回。

filterByGeometry (query_geometry_or_extent)

过滤栅格项目的集合,以便仅返回与几何相交的栅格项目。

filterByRasterProperty (property_name, operator, property_values)

按栅格属性查询过滤栅格项目的集合,并返回仅包含满足查询的项目的栅格集合。

filterByTime ({start_time}, {end_time}, {time_field_name}, {date_time_format})

按时间范围过滤栅格项目的集合,并返回仅包含满足过滤器的项目的栅格集合。

getFieldValues (field_name, {max_count})

返回栅格集合中指定字段的值。

majority ({ignore_nodata}, {extent_type}, {cellsize_type})

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上出现最频繁的像素值。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 majority 方法将确定在波段 1、波段 2、波段 3 和波段 4 的所有栅格项目上出现最频繁的像素值;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

map (func)

将 Python 函数映射到栅格集合。

max ({ignore_nodata}, extent_type, cellsize_type)

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上的最大像素值。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 max 方法将计算在波段 1、波段 2、波段 3 和波段 4 的所有栅格项目上出现的最大像素值;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

mean ({ignore_nodata}, {extent_type}, {cellsize_type})

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上的平均像素值。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 mean 方法将计算在波段 1、波段 2、波段 3 和波段 4 的所有栅格项目上出现的平均像素值;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

median ({ignore_nodata}, {extent_type}, {cellsize_type})

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上的像素中值。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 median 方法将计算在波段 1、波段 2、波段 3 和波段 4 的所有栅格项目上出现的像素中值;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

min ({ignore_nodata}, {extent_type}, {cellsize_type})

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上的最低像素值。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 min 方法将计算在波段 1、波段 2、波段 3 和波段 4 的所有栅格项目上出现的最小像素值;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

mosaic ({mosaic_method})

返回一个栅格数据集,其中栅格集合中的所有项目都已镶嵌到单个栅格中。

qualityMosaic (quality_rc_or_list, {statistic_type})

返回一个栅格数据集,其中栅格集合中的所有项目都已根据质量要求镶嵌到单个栅格中。

selectBands (band_ids_or_names)

选择栅格集合中每个栅格项目的波段列表,并返回包含仅具有所选波段的栅格项目的栅格集合。

sort (field_name, {ascending})

按字段名称对栅格集合进行排序,然后返回指定顺序的栅格集合。

std ({ignore_nodata}, {extent_type}, {cellsize_type})

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上的像素标准差值。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 std 方法将计算在波段 1、2、3 和 4 的所有栅格项目上出现的像素标准差值;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

sum ({ignore_nodata}, {extent_type}, {cellsize_type})

返回一个栅格对象,其中每个波段都包含该波段在栅格集合中的所有栅格上的像素值之和。

例如,如果栅格集合中有 10 个栅格项目,每个栅格项目包含 4 个波段,则 sum 方法将计算在波段 1、波段 2、波段 3 和波段 4 的所有栅格项目上出现的每个像素的像素值之和;将返回四波段栅格。 波段号需要使用波段指数在栅格项目之间进行匹配,因此栅格集合中的项目必须遵循相同的波段顺序。

summarizeField (field_name, {summary_type})

汇总栅格集合的给定字段中的对象。

toMultidimensionalRaster (variable_field_name, dimension_field_names)

返回多维栅格数据集,其中栅格集合中的每个项目均为多维栅格中的一个剖切。

方法

filter ({where_clause}, {query_geometry_or_extent})
参数说明数据类型
where_clause

用于限制所返回的记录的表达式。有关 WHERE 子句和 SQL 语句的详细信息,请参阅在 ArcGIS 中使用的查询表达式的 SQL 参考

(默认值为 None)

String
query_geometry_or_extent

此对象用于过滤项目,以便仅返回与该对象相交的项目。

可以使用 Geometry 对象、Extent 对象、Raster 对象或要素类的路径进行指定。

(默认值为 None)

Geometry
返回值
数据类型说明
RasterCollection

满足属性或几何查询的栅格集合。

filterByAttribute (field_name, operator, field_values)
参数说明数据类型
field_name

过滤器中使用的字段名称。

String
operator

用于过滤属性的关键字。关键字包括以下内容:

  • CONTAINS字段中的属性包含指定的字符串、列表或数字。
  • ENDS_WITH该属性以指定的字符串或数字结尾。
  • EQUALS该属性等于指定的字符串、列表或数字。
  • GREATER_THAN该属性大于指定数字。
  • IN该属性是指定列表中的一个项目。
  • LESS_THAN该属性小于指定数字。
  • NOT_CONTAINS该属性不包含指定的字符串、列表或数字。
  • NOT_ENDS_WITH该属性不以指定的字符串或数字结尾。
  • NOT_EQUALS该属性不等于指定的字符串、列表或数字。
  • NOT_GREATER_THAN该属性不大于指定数字。
  • NOT_IN该属性不是指定列表中的一个项目。
  • NOT_LESS_THAN该属性不小于指定数字。
  • NOT_STARTS_WITH该属性不以指定的字符串或数字开头。
  • STARTS_WITH该属性以指定的字符串或数字开头。
String
field_values
[field_values,...]

要比较的一个或多个属性值。可以将其指定为字符串、列表或数字。

String
返回值
数据类型说明
RasterCollection

满足属性查询的栅格集合。

filterByCalendarRange (calendar_field, start, {end}, time_field_name, date_time_format)
参数说明数据类型
calendar_field

日历字段的名称。指定以下内容之一:HOURDAY_OF_WEEKDAY_OF_MONTHDAY_OF_YEARWEEK_OF_YEARMONTHYEARQUARTER

String
start

calendar_field 的起始值。例如,要过滤一月份 filtered_rc = rc.filterByCalendarRange(calendar_field="MONTH", start=1)收集的所有项目。

Integer
end

calendar_field 的结束值。例如,要过滤每年前 5 天收集的所有项目,filtered_rc = rc.filterByCalendarRange(calendar_field="DAY_OF_YEAR", start=1, end=5)

Integer
time_field_name

包含集合中每个项目的时间属性的字段名称。默认设置为 StdTime

String
date_time_format

时间字段中值的时间格式。例如,如果输入时间值为 "1990-01-31",则 date_time_format 为 "%Y-%m-%d"。

String
返回值
数据类型说明
RasterCollection

满足时间范围查询的栅格集合。

filterByGeometry (query_geometry_or_extent)
参数说明数据类型
query_geometry_or_extent

此对象用于过滤项目,以便仅返回与该对象相交的项目。可以使用 Geometry 对象、Extent 对象、Raster 对象或要素类的路径进行指定。

Geometry
返回值
数据类型说明
RasterCollection

满足几何过滤器的栅格集合。

filterByRasterProperty (property_name, operator, property_values)
参数说明数据类型
property_name

过滤器中使用的属性的名称。

String
operator

用于过滤属性的运算符。

  • CONTAINS该属性包含指定的字符串、列表或数字。
  • ENDS_WITH该属性以指定的字符串或数字结尾。
  • EQUALS该属性等于指定的字符串、列表或数字。
  • GREATER_THAN该属性大于指定数字。
  • IN该属性是指定列表中的一个项目。
  • LESS_THAN该属性小于指定数字。
  • NOT_CONTAINS该属性不包含指定的字符串、列表或数字。
  • NOT_ENDS_WITH该属性不以指定的字符串或数字结尾。
  • NOT_EQUALS该属性不等于指定的字符串、列表或数字。
  • NOT_GREATER_THAN该属性不大于指定数字。
  • NOT_IN该属性不是指定列表中的一个项目。
  • NOT_LESS_THAN该属性不小于指定数字。
  • NOT_STARTS_WITH该属性不以指定的字符串或数字开头。
  • STARTS_WITH该属性以指定的字符串或数字开头。
String
property_values
[property_values,...]

要比较的一个或多个属性值。可以将其指定为字符串、列表或数字。

String
返回值
数据类型说明
RasterCollection

满足属性查询的栅格集合。

filterByTime ({start_time}, {end_time}, {time_field_name}, {date_time_format})
参数说明数据类型
start_time

用于指定起始时间的字符串。字符串的格式应与输入栅格集合的日期格式相匹配,例如“1990-01-01T13:30:00”。如果未指定,则必须指定结束时间,且仅会返回时间值早于或等于结束时间的项目。

(默认值为 None)

String
end_time

用于指定结束时间的字符串。字符串的格式应与输入栅格集合的日期格式相匹配,例如“1991-01-01T13:30:00”。如果未指定,则必须指定开始时间,且仅会返回时间值晚于或等于开始时间的项目。

(默认值为 None)

String
time_field_name

包含集合中每个项目的时间属性的字段名称。

(默认值为 StdTime)

String
date_time_format

start_timeend_time 值的格式。例如,如果提供的 start_time 值为 "1990-01-31",则 date_time_format 为 "%Y-%m-%d."。对于包含时间部分的日期,例如 "1990-01-31T00:00:00",默认格式为 "%Y-%m-%dT%H:%M:%S"。

String
返回值
数据类型说明
RasterCollection

满足时间范围过滤器的栅格集合。

getFieldValues (field_name, {max_count})
参数说明数据类型
field_name

要从中提取值的字段的名称。

String
max_count

一个用于指定要返回的最大字段值数量的整数。该值将按照集合中栅格项目的排序顺序返回。如果未指定任何值,则将返回给定字段的所有字段值。

(默认值为 None)

Integer
返回值
数据类型说明
String

指定字段名称的字段值列表。

majority ({ignore_nodata}, {extent_type}, {cellsize_type})
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
cellsize_type

Computes the cell size of the output raster object when the input rasters have different cell sizes.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
返回值
数据类型说明
Raster

此栅格中的每个波段均包含该波段在栅格集合中所有项目上出现最频繁的像素值。

map (func)
参数说明数据类型
func

要映射到栅格集合的 Python 函数。该函数的返回值必须是其中一个键为 raster 的字典。例如,{"raster": output_raster_object, "name": input_item_name["name"]}

def NDVI(item):
    """Define a Python function to calculate NDVI"""
    # Create the raster object from the item
    raster_obj = item['Raster']
    # Create raster objects for the red and NIR bands
		  red, nir = raster_obj.getRasterBands(["red", "nir"])
    # Compute NDVI
    ndvi = (nir-red)/(nir+red)
    return {"raster": ndvi, "name": item['Name'], "stdTime": item['AcquisitionDate']}
ndvi_rc = rc.map(NDVI)

Function
返回值
数据类型说明
RasterCollection

此栅格集合中的每个项目均包含已应用函数并已附加属性的栅格。

max ({ignore_nodata}, extent_type, cellsize_type)
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent using the extent of the last input raster.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
cellsize_type

Computes the cell size of the output raster object when the input rasters have different cell sizes.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
返回值
数据类型说明
Raster

此栅格中的每个波段都包含该波段在栅格集合中的所有栅格上的最大像素值。

mean ({ignore_nodata}, {extent_type}, {cellsize_type})
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the total extent of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
cellsize_type

Computes the cell size of the output raster object when the input rasters have different cell sizes.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
返回值
数据类型说明
Raster

此栅格中的每个波段都包含该波段在栅格集合中的所有栅格上的平均像素值。

median ({ignore_nodata}, {extent_type}, {cellsize_type})
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
cellsize_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
返回值
数据类型说明
Raster

此栅格中的每个波段都包含该波段在栅格集合中的所有栅格上的像素中值。

min ({ignore_nodata}, {extent_type}, {cellsize_type})
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
cellsize_type

Computes the cell size of the output raster object when the input rasters have different cell sizes.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
返回值
数据类型说明
Raster

此栅格中的每个波段都包含该波段在栅格集合中的所有栅格上的最低像素值。

mosaic ({mosaic_method})
参数说明数据类型
mosaic_method

用于处理相邻栅格项目之间的重叠区域的方法。镶嵌方法选项包括以下内容:

  • FIRST 根据重叠的第一个栅格确定像素值。
  • LAST根据重叠的最后一个栅格确定像素值。
  • MEAN根据两个重叠的栅格确定平均像素值。
  • MINIMUM根据两个重叠的栅格数据集确定较低的像素值。
  • MAXIMUM根据两个重叠的栅格数据集确定较高的像素值。
  • SUM根据两个重叠的栅格确定像素值之和。

有关镶嵌方法的详细信息,请参阅镶嵌运算符

(默认值为 First)

String
返回值
数据类型说明
Raster

包含来自栅格集合的镶嵌栅格项目的栅格数据集。

qualityMosaic (quality_rc_or_list, {statistic_type})
参数说明数据类型
quality_rc_or_list

用作质量指标的栅格集合或栅格列表。

例如,Landsat 8 的波段 1 是“沿海/气溶胶”波段,可用于估算大气中细小气溶胶颗粒(例如烟尘和烟雾)的浓度。对于 Landsat 8 影像集合,请使用 selectBands 方法从每个栅格项目返回仅包含 波段 1 的 RasterCollection 对象。quality_rc_or_list 中的栅格项目数必须与要镶嵌的栅格集合中的栅格项目数相匹配。

RasterCollection
statistic_type

用于比较输入集合或质量栅格列表的统计数据。

  • MAX输入质量栅格中的最高像素值将是输出栅格中的像素值。这是默认设置。
  • MEDIAN输入质量栅格中的像素中值将是输出栅格中的像素值。
  • MIN输入质量栅格中的最小像素值将是输出栅格中的像素值。

例如,如需镶嵌输入栅格集合以使气溶胶含量最低的栅格位于顶部,请使用 MIN 统计类型。

String
返回值
数据类型说明
Raster

包含来自栅格集合的镶嵌栅格项目的栅格数据集。

selectBands (band_ids_or_names)
参数说明数据类型
band_ids_or_names
[band_ids_or_names,...]

要包含在返回的栅格项目中的波段名称或索引编号。可以使用单个字符串、整数或者字符串或整数的列表来进行指定。

Object
返回值
数据类型说明
RasterCollection

仅包含所选波段的栅格集合。

sort (field_name, {ascending})
参数说明数据类型
field_name

用于排序的字段名称。

String
ascending

指定按升序还是降序进行排序。

(默认值为 True)

Boolean
返回值
数据类型说明
RasterCollection

已排序的栅格项目集合。

std ({ignore_nodata}, {extent_type}, {cellsize_type})
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the total extent of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
cellsize_type

Computes the cell size of the output raster object when the input rasters have different cell sizes.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.

(默认值为 FirstOf)

String
返回值
数据类型说明
Raster

栅格中每个波段都包含该波段在栅格集合中的所有栅格上的像素标准差值。

sum ({ignore_nodata}, {extent_type}, {cellsize_type})
参数说明数据类型
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(默认值为 True)

Boolean
extent_type

Computes the extent of the output raster object when the input rasters have different extents.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.
String
cellsize_type

Computes the cell size of the output raster object when the input rasters have different cell sizes.

  • FirstOfDefines the output extent using the extent of the first input raster.
  • IntersectionOfDefines the output extent as the intersecting area of the input rasters.
  • UnionOfDefines the output extent as the total extent of the input rasters.
  • LastOfDefines the output extent using the extent of the last input raster.
String
返回值
数据类型说明
Raster

此栅格中的每个波段都包含该波段在栅格集合中的所有栅格上的像素值之和。

summarizeField (field_name, {summary_type})
参数说明数据类型
field_name

The field name to summarize.

String
summary_type
[summary_type,...]

The summary methods to calculate for the selected field. One or more methods can be specified.

  • COUNTCalculates the number of non-null values of the selected field.
  • COUNT_DISTINCTCalculates the number of distinct values of the selected field.
  • FIRSTCalculates the field value of the first object in the collection.
  • HISTOGRAMCalculates a histogram of the selected field.
  • MAXCalculates the maximum of the values of the selected field.
  • MEANCalculates the mean of the selected field.
  • MINCalculates the minimum of the values of the selected field.
  • PRODUCTCalculates the product of the values of the selected field.
  • SAMPLE_SDCalculates the sample standard deviation of the values of the selected field.
  • SAMPLE_VARCalculates the sample variance of the values of the selected field.
  • SUMCalculates the sum of the values of the selected field.
  • TOTAL_SDCalculates the total standard deviation of the values of the selected field.
  • TOTAL_VARCalculates the total variance of the values of the selected field.
  • ALLCalculates all the above statistics of the selected field.

(默认值为 ALL)

String
返回值
数据类型说明
Dictionary

汇总方法和值的字典。

toMultidimensionalRaster (variable_field_name, dimension_field_names)
参数说明数据类型
variable_field_name

包含变量名称的字段的名称。

String
dimension_field_names
[dimension_field_names,...]

包含维度名称的一个或多个字段的名称。可将其指定为单个字符串或字符串列表。

对于与时间相关的维度,如需被识别为时间字段,则字段名称必须与以下选项之一相匹配:StdTimeDateTimeAcquisitionDate。对于与时间无关的维度,这些字段中的值必须为双精度。如果有两个或多个维度,请使用逗号分隔字段(例如 dimension_field_names = ["Time", "Depth"])。

String
返回值
数据类型说明
Raster

多维栅格对象。栅格集合中的每个项目都是多维栅格中的一个剖切。

代码示例

RasterCollection 示例 1(Python 窗口)

根据镶嵌数据集创建栅格集合,并按日期过滤集合。

# Import system modules
import arcpy
from arcpy.ia import *

# Construct a collection from a mosaic dataset
rc = RasterCollection(r'C:\data.gdb\time_series_landsat_images')

# Filter the collection to extract all images before year 2009
filtered_rc = rc.filterByTime(end_time = '2009-01-01T00:00:00', 
	time_field_name = 'AcquisitionDate')

# Return the dates in the filtered collection
dates = filtered_rc.getFieldValues('AcquisitionDate')
RasterCollection 示例 2(Python 窗口)

根据镶嵌数据集创建栅格集合,并按几何过滤集合。

# Import system modules
import arcpy
from arcpy.ia import *

# Construct a collection from a mosaic dataset
rc = RasterCollection(r'C:\data.gdb\time_series_landsat_images')

# Define line geometry 
line = arcpy.Polyline(arcpy.Array([arcpy.Point(54.9243963, 23.9279934), 
	arcpy.Point(55.29, 25.6)]),arcpy.SpatialReference(4326))

# Filter the collection to extract images that intersect with line geometry
filtered_rc = rc.filterByGeometry(line)

# Return the total number of items in the filtered collection
count = filtered_rc.count
RasterCollection 示例 3(独立脚本)

根据镶嵌数据集创建栅格集合,并按属性过滤集合。

# Name: RasterCollection_Ex_03.py
# Description: Generates a raster collection from a mosaic dataset and
#	filters by an attribute field
# Requirements: ArcGIS Image Analyst 

# Import system modules
import arcpy
from arcpy.ia import *

# Define arguments
mosaic_dataset = r'C:\data.gdb\time_series_landsat_images'

# Construct a collection from a mosaic dataset
rc = RasterCollection(mosaic_dataset)

# Filter the collection to extract only images from Landsat 7
Landsat7_rc = rc.filterByAttribute("SensorName", "contain", "Landsat7")

# Return the names of the sensors in the filtered collection to double confirm
sensors= Landsat7_rc.getFieldValues(field_name)
RasterCollection 示例 4(Python 窗口)

从表示 NDVI 的栅格列表中创建一个栅格集合,然后返回该集合中每个像素的最大 NDVI 值。

# Import system modules
import arcpy
from arcpy.ia import *
from arcpy import env

# Set workspace
arcpy.env.workspace = "C:/Data/NDVI"

# Get the list of tiff files from the workspace
NDVI_tiff_list = arcpy.ListRasters("*", "TIF")

# Generate a list of raster file names without the .tif extension 
name_list = []
for NDVI in NDVI_tiff_list:
    name_list.append(NDVI.replace(".tif","")

# Construct a collection from the list of raster file names
rc = RasterCollection(NDVI_tiff_list, {'name':name_list})

# Return a raster object where every pixel contains the 
# maximum value of that pixel over the entired NDVI raster collection
max_NDVI_rc = rc.max()

# Save the new raster object
max_NDVI_rc.save(r'C:\output\max_NDVI_raster.tif')
RasterCollection 示例 5(Python 窗口)

将 Python 函数映射到栅格集合以生成新集合。

# Import system modules
import arcpy
from arcpy.ia import *

arcpy.CheckOutExtension("ImageAnalyst")

# Construct a collection from a mosaic dataset
rc = RasterCollection(r'C:\Data.gdb\Landsat8_TimeSeries')

# Define a Python function to calculate the Soil Adjusted Vegetation Index (SAVI) 
def SAVI(item):
	# Get the raster object from the item
	raster = item['Raster']
	# Get the raster objects for the NIR and Red bands
	Red_band, NIR_band = raster.getRasterBands(["red","nir"])
	# Compute the index
	savi_index = ((1.5 * (NIR_band - Red_band))/(NIR_band + Red_band + 0.5))
	return{"raster": savi_index, "name": "Soil_Adjusted_Vegetation_Index", "StdTime":item['AcquisitionDate']}
	
# Run the Python function over the raster collection and generate a new collection
SAVI_rc = rc.map(SAVI)

# save it as a multidimensional raster
mdim_raster = SAVI_rc.toMultidimensionalRaster(variable_field_name = "name", dimension_field_names = "StdTime")
mdim_raster.save(r'C:\output\time_series_SAVI_raster.crf')