RasterCollection

Synthèse

Defines the group of input rasters and attributes to include in a collection that will be used for processing.

Discussion

The RasterCollection object allows a group of rasters to be sorted and filtered, and prepares a collection for additional processing and analysis.

The RasterCollection object includes the max, min, median, mean, majority, and sum methods for calculating statistics for each pixel across matching bands within the collection's rasters.

For example, the sum method adds the pixel values from Band 1 in raster item 1 to the pixel values in Band 1 of raster item 2, and returns a Raster object in which Band 1 contains those summed values.

The sum method for the RasterCollection class

Syntaxe

RasterCollection (rasters, {attribute_dict})
ParamètreExplicationType de données
rasters
[rasters,...]

The input raster datasets. Supported inputs include a list of rasters, a mosaic dataset, a multidimensional raster in Cloud Raster Format, a NetCDF file, or an image service. If you're using a list of raster datasets, all rasters must have the same cell size and spatial reference.

List
attribute_dict

A Python dictionary that contains attribute information to be added to each raster, when the input is a list of rasters. For each key-value pair, the key is the attribute name and the value is a list of values that represent the attribute value for each raster. For example, to add a name field to a list of three rasters, use {"name": ["Landsat8_Jan", "Landsat8_Feb", "Landsat8_Mar"]}.

(La valeur par défaut est None)

Dictionary

Propriétés

PropriétéExplicationType de données
fields
(Lecture seule)

The list of field names included in the raster collection.

String
count
(Lecture seule)

The total number of items in the raster collection.

Integer

Vue d’ensemble des méthodes

MéthodeExplication
addField (field_name, field_values)

Adds a new field to the raster collection and populates it with values.

filter ({where_clause}, {query_geometry_or_extent})

Filters the collection of raster items by attributes or geometry and returns a raster collection containing only the items that satisfy the filter. If no arguments are provided, all raster items from the raster collection will be returned in a new raster collection.

filterByAttribute (field_name, operator, field_values)

Filters the collection of raster items by an attribute query and returns a raster collection containing only the items that satisfy the query.

To query the raster collection based on a time field, use the filterByTime method.

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

Filters the collection of raster items based on the range of a calendar field and returns a raster collection containing only the items that satisfy the filter. If no arguments are provided, all raster items from the raster collection will be returned in a new raster collection.

filterByGeometry (query_geometry_or_extent)

Filters the collection of raster items so that only those that intersect with the geometry will be returned.

filterByRasterProperty (property_name, operator, property_values)

Filters the collection of raster items by a raster property query and returns a raster collection containing only the items that satisfy the query.

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

Filters the collection of raster items by a time range and returns a raster collection containing only the items that satisfy the filter.

fromSTACAPI (stac_api, {query}, {attribute_dict}, {request_method}, {request_params}, {context})

Creates a RasterCollection object from a SpatioTemporal Asset Catalog (STAC) API search query.

fromSTACCatalog (stac_catalog, {attribute_dict}, {request_params}, {context})

Creates a RasterCollection object from a static SpatioTemporal Asset Catalog (STAC).

getFieldValues (field_name, {max_count})

Returns the values of a specified field from the raster collection.

groupBy (field_name)

Groups a raster collection based on a field. Each grouped raster collection can be accessed by the field value.

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

Returns a raster object in which each band contains the pixel value that occurs most frequently for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the majority method will determine the pixel value that occurs most frequently across all raster items for band 1, for band 2, for band 3, and for band 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

map (func)

Maps a Python function over a raster collection.

max ({ignore_nodata}, extent_type, cellsize_type)

Returns a raster object in which each band contains the maximum pixel values for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the max method will calculate the maximum pixel value that occurs across all raster items for band 1, band 2, band 3, and band 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

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

Returns a raster object in which each band contains the average pixel values for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the mean method will calculate the mean pixel value that occurs across all raster items for band 1, band 2, band 3, and band 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

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

Returns a raster object in which each band contains the median pixel values for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the median method will calculate the median pixel value that occurs across all raster items for band 1, band 2, band 3, and band 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

merge (collection2)

Returns a merged raster collection that includes all rasters from two raster collections.

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

Returns a raster object in which each band contains the lowest pixel values for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the min method will calculate the minimum pixel value that occurs across all raster items for band 1, band 2, band 3, and band 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

mosaic ({mosaic_method})

Returns a raster dataset in which all items in a raster collection have been mosaicked into a single raster.

qualityMosaic (quality_rc_or_list, {statistic_type})

Returns a raster dataset in which all items in a raster collection have been mosaicked into a single raster based on a quality requirement.

reduce (func, {func_args})

Returns a raster object where all images in the collection are combined into a single image based on a reducer function.

For example, if there are ten raster items in the raster collection, each with four bands, the Min method can be specified as the reducer function. This will return a four-band raster, with each band containing the minimum values across all ten rasters.

selectBands (band_ids_or_names)

Selects a list of bands from every raster item in a raster collection and returns a raster collection that contains raster items with only the selected bands.

sort (field_name, {ascending})

Sorts the collection of rasters by a field name and returns a raster collection that is in the order specified.

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

Returns a raster object in which each band contains the standard deviation pixel values for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the std method will calculate the standard deviation pixel value that occurs across all raster items for bands 1, 2, 3, and 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

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

Returns a raster object in which each band contains the sum of pixel values for that band across all rasters in the raster collection.

For example, if there are 10 raster items in the raster collection, each with four bands, the sum method will calculate the sum of pixel values for each pixel that occurs across all raster items for band 1, band 2, band 3, and band 4; a four-band raster is returned. Band numbers are matched between raster items using the band index, so the items in the raster collection must follow the same band order.

summarizeField (field_name, {summary_type})

Summarizes the objects in a given field for a raster collection.

toMultidimensionalRaster (variable_field_name, dimension_field_names)

Returns a multidimensional raster dataset, in which each item in the raster collection is a slice in the multidimensional raster.

Méthodes

addField (field_name, field_values)
ParamètreExplicationType de données
field_name

The name of the field to be added.

String
field_values
[field_values,...]

The list of values associated with the field name. The length of the list should match the number of items in the raster collection.

List
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that contain the new field.

filter ({where_clause}, {query_geometry_or_extent})
ParamètreExplicationType de données
where_clause

An expression that limits the records returned. For more information on WHERE clauses and SQL statements, see SQL reference for query expressions used in ArcGIS.

(La valeur par défaut est None)

String
query_geometry_or_extent

An object that filters the items such that only those that intersect with the object will be returned.

This can be specified with a Geometry object, Extent object, Raster object, or a path to a feature class.

(La valeur par défaut est None)

Geometry
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the attribute or geometry queries.

filterByAttribute (field_name, operator, field_values)
ParamètreExplicationType de données
field_name

The field name to use in the filter.

String
operator

The keyword to filter the attributes. Keywords include the following:

  • CONTAINSThe attribute in the field contains the specified string, list, or number.
  • ENDS_WITHThe attribute ends with the specified string or number.
  • EQUALSThe attribute equals the specified string, list, or number.
  • GREATER_THANThe attribute is greater than the specified number.
  • INThe attribute is one of the items in the specified list.
  • LESS_THANThe attribute is less than the specified number.
  • NOT_CONTAINSThe attribute does not contain the specified string, list, or number.
  • NOT_ENDS_WITHThe attribute does not end with the specified string or number.
  • NOT_EQUALSThe attribute does not equal the specified string, list, or number.
  • NOT_GREATER_THANThe attribute is not greater than the specified number.
  • NOT_INThe attribute is not one of the items in the specified list.
  • NOT_LESS_THANThe attribute is not less than the specified number.
  • NOT_STARTS_WITHThe attribute does not start with the specified string or number.
  • STARTS_WITHThe attribute starts with the specified string or number.
String
field_values
[field_values,...]

The attribute value or values against which to compare. This can be specified as a string, a list, or a number.

String
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the attribute query.

filterByCalendarRange (calendar_field, start, {end}, time_field_name, date_time_format)
ParamètreExplicationType de données
calendar_field

The name of the calendar field. Specify one of the following: HOUR, DAY_OF_WEEK, DAY_OF_MONTH, DAY_OF_YEAR, WEEK_OF_YEAR, MONTH, YEAR, or QUARTER.

String
start

The start value of the calendar_field. For example, to filter all items that were collected in January, filtered_rc = rc.filterByCalendarRange(calendar_field="MONTH", start=1).

Integer
end

The end value of the calendar_field. For example, to filter all items that were collected in the first five days of each year, filtered_rc = rc.filterByCalendarRange(calendar_field="DAY_OF_YEAR", start=1, end=5).

Integer
time_field_name

The name of the field that contains the time attribute for each item in the collection. The default is StdTime.

String
date_time_format

The time format of the values in the time field. For example, if the input date and time value is "1990-01-31T00:00:00", the date_time_format is "%Y-%m-%dT%H:%M:%S". If only the date value is required, date_time_format can be specified as "%Y-%m-%d".

String
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the time range query.

filterByGeometry (query_geometry_or_extent)
ParamètreExplicationType de données
query_geometry_or_extent

An object that filters the items such that only those that intersect with the object will be returned. This can be specified with a Geometry object, Extent object, Raster object, or a path to a feature class.

Geometry
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the geometry filter.

filterByRasterProperty (property_name, operator, property_values)
ParamètreExplicationType de données
property_name

The name of the property to use in the filter.

String
operator

The operator to filter the property.

  • CONTAINSThe property contains the specified string, list, or number.
  • ENDS_WITHThe property ends with the specified string or number.
  • EQUALSThe property equals the specified string, list, or number.
  • GREATER_THANThe property is greater than the specified number.
  • INThe property is one of the items in the specified list.
  • LESS_THANThe property is less than the specified number.
  • NOT_CONTAINSThe property does not contain the specified string, list, or number.
  • NOT_ENDS_WITHThe property does not end with the specified string or number.
  • NOT_EQUALSThe property does not equal the specified string, list, or number.
  • NOT_GREATER_THANThe property is not greater than the specified number.
  • NOT_INThe property is not one of the items in the specified list.
  • NOT_LESS_THANThe property is not less than the specified number.
  • NOT_STARTS_WITHThe property does not start with the specified string or number.
  • STARTS_WITHThe property starts with the specified string or number.
String
property_values
[property_values,...]

The property value or values against which to compare. This can be specified as a string, a list, or a number.

String
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the property query.

filterByTime ({start_time}, {end_time}, {time_field_name}, {date_time_format})
ParamètreExplicationType de données
start_time

A string that specifies the start time. The string should be formatted to match the date format of the input raster collections, for example, "1990-01-01T13:30:00". If not specified, the end time must be specified, and only the items that have a time value that is earlier than or equal to the end time will be returned.

(La valeur par défaut est None)

String
end_time

A string that specifies the end time. The string should be formatted to match the date format of the input raster collections, for example, "1991-01-01T13:30:00". If not specified, the start time must be specified, and only the items that have a time value that is later than or equal to the start time will be returned.

(La valeur par défaut est None)

String
time_field_name

The name of the field that contains the time attribute for each item in the collection.

(La valeur par défaut est StdTime)

String
date_time_format

The format of the start_time and end_time values. For example, if the provided start_time value is "1990-01-31", the date_time_format is "%Y-%m-%d." For dates that include a time component, such as "1990-01-31T00:00:00", the default format is "%Y-%m-%dT%H:%M:%S".

String
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the time range filter.

fromSTACAPI (stac_api, {query}, {attribute_dict}, {request_method}, {request_params}, {context})
ParamètreExplicationType de données
stac_api

The URL of the STAC API root endpoint. This is the STAC API where the search will be performed, for example, "https://planetarycomputer.microsoft.com/api/stac/v1".

The following STAC APIs are supported:

  • https://planetarycomputer.microsoft.com/api/stac/v1—The following collections are supported: daymet-annual-pr, daymet-daily-hi, 3dep-seamless, 3dep-lidar-dsm, sentinel-1-rtc, gridmet, daymet-annual-na, daymet-monthly-na, daymet-annual-hi, daymet-monthly-hi, daymet-monthly-pr, hgb, cop-dem-glo-30, cop-dem-glo-90, terraclimate, gnatsgo-rasters, 3dep-lidar-hag, 3dep-lidar-intensity, 3dep-lidar-pointsourceid, mtbs, noaa-c-cap, alos-fnf-mosaic, 3dep-lidar-returns, mobi, landsat-c2-l2, chloris-biomass, daymet-daily-pr, 3dep-lidar-dtm-native, 3dep-lidar-classification, 3dep-lidar-dtm, gap, alos-dem, jrc-gsw, hrea, sentinel-2-l2a, daymet-daily-na, nrcan-landcover, ecmwf-forecast, noaa-mrms-qpe-24h-pass2, sentinel-1-grd, nasadem, io-lulc, landsat-c2-l1, drcog-lulc, chesapeake-lc-7, chesapeake-lc-13, chesapeake-lu, noaa-mrms-qpe-1h-pass1, noaa-mrms-qpe-1h-pass2, noaa-nclimgrid-monthly, usda-cdl, esa-cci-lc, esa-cci-lc-netcdf, noaa-climate-normals-netcdf, noaa-climate-normals-gridded, io-lulc-9-class, io-biodiversity, naip, noaa-cdr-sea-surface-temperature-whoi, noaa-cdr-ocean-heat-content, noaa-cdr-sea-surface-temperature-whoi-netcdf, sentinel-3-olci-wfr-l2-netcdf, noaa-cdr-ocean-heat-content-netcdf, sentinel-3-synergy-v10-l2-netcdf, sentinel-3-olci-lfr-l2-netcdf, sentinel-3-slstr-lst-l2-netcdf, sentinel-3-slstr-wst-l2-netcdf, sentinel-3-synergy-syn-l2-netcdf, sentinel-3-synergy-vgp-l2-netcdf, sentinel-3-synergy-vg1-l2-netcdf, esa-worldcover, modis-64A1-061, modis-17A2H-061, modis-11A2-061, modis-17A2HGF-061, modis-17A3HGF-061, modis-09A1-061, modis-16A3GF-061, modis-21A2-061, modis-43A4-061, modis-09Q1-061, modis-14A1-061, modis-13Q1-061, modis-14A2-061, modis-15A2H-061, modis-11A1-061, modis-15A3H-061, modis-13A1-061, modis-10A2-061, modis-10A1-061, and aster-l1t.
  • https://earth-search.aws.element84.com/v0—All collections are supported.
  • https://earth-search.aws.element84.com/v1—All collections are supported.
  • https://services.sentinel-hub.com/api/v1/catalog—All collections are supported.
  • https://landsatlook.usgs.gov/stac-server—All collections are supported.
  • https://geoportalstac.azurewebsites.net/stac—All collections are supported.
  • https://gpt.geocloud.com/sentinel/stac—All collections are supported.
String
query

The GET or POST request query dictionary that will be used to query a STAC API search endpoint. The key-value pairs depend on the specification of the stac_api value and the request_method value.

{
"collections": ["sentinel-2-l2a"],
"bbox": [-110, 39.5, -105, 40.5],
"query": {"eo:cloud_cover": {"lt": 0.5}},
"datetime": "2020-10-05T00:00:00Z/2020-10-10T12:31:12Z",
"limit": 100
}

For the bbox key, Extent and Polygon objects are also accepted (in any spatial reference).

Dictionary
attribute_dict

The attribute information that will be added to each STAC item raster returned from the query. For each key-value pair, the key is the attribute name, and the value is a list of values that represent the attribute value for each raster.

Attribute values can also be collected from the STAC items automatically using the STAC item metadata information. To do this, specify the STAC item property name for the attribute of interest as key-value pairs (attribute display name: STAC item property name).

{
"Name": "id",
"Sensor": "platform",
"StdTime": "datetime",
"Cloud Cover": "eo:cloud_cover",
"Spatial Reference": "proj:epsg",
"Extent": "bbox"
}

Remarque :

If no Geometry key is specified, it will be automatically added for each raster in the RasterCollection object based on its STAC item's geometry property and will be in "Spatial Reference": {"wkid": 4326}.

Dictionary
request_method

Specifies the HTTP request method that will be used with the STAC API for the search.

  • GET—A GET request will be sent to the STAC API.
  • POST—A POST request will be sent to the STAC API.

Example: "POST"

(La valeur par défaut est POST)

String
request_params

The parameters of the STAC API search request.

Specify the requests.post() or requests.get() method parameters and values in dictionary format.

{
"verify": False,
"headers": {"Authorization": "Bearer access_token_string"}
}
Dictionary
context

Additional properties that will be used to control the creation of the object.

The dictionary supports the assetManagement and processingTemplate keys.

The assetManagement key specifies how to manage and select assets for the RasterCollection object. If multiple assets are selected, the collection will be composed of multiband rasters from those selected asset types. The value can be a list, string, or dictionary.

When working with individual assets, the asset key can be specified directly, for example, "B02" or {"key": "B02"}, or as a list. Each item in the list represents an asset key or identifier. Items in the list can be strings representing the asset key directly, or dictionaries providing additional details for locating the asset.

If the value of the assetManagement key is a dictionary, the following keys are supported:

  • key—A string representing the unique identifier for an asset, for example, "red".
  • path—A list representing the hierarchy of keys to navigate to the asset, for example, ["alternate", "s3"].
  • hrefKey—A string representing the key to access the asset URL, for example, "msft:https-url". If this value is different from the default href key, specify it here.

Examples:

{
    "assetManagement": [
        "red",
        "blue"
    ]
}
{
    "assetManagement": {
       "key": "tasmin",
       "hrefKey": "msft:https-url"
    }
}
{
    "assetManagement": [
       {"key": "TRAD",
        "path": ["alternate", "s3"]},
       {"key": "DRAD", 
        "path": ["alternate", "s3"]}
    ]
}

The processingTemplate key specifies the processing template that will be applied to the individual rasters in the collection. This is supported for selected collections and raster types. For more information about collections and raster types, see Satellite sensor raster types. The default for supported raster types is "Multiband"; otherwise, it's None.

Example:

{
    "processingTemplate": "Surface Reflectance"
}
Dictionary
Valeur renvoyée
Type de donnéesExplication
RasterCollection

A new instance of this class is returned

Use the GetSTACInfo function to gather necessary STAC information, which can then be used to create Raster objects with this method.

fromSTACCatalog (stac_catalog, {attribute_dict}, {request_params}, {context})
ParamètreExplicationType de données
stac_catalog

The URL of the STAC item, a pystac.Catalog object, or a pystac.Collection object. If a URL is provided, the value must be a static STAC item URL or a STAC API item URL, for example, "https://maxar-opendata.s3.amazonaws.com/events/India-Floods-Oct-2023/collection.json".

The following static catalogs (and their underlying child catalogs) are supported:

String
attribute_dict

The attribute information that will be added to each STAC item raster returned from the query. For each key-value pair, the key is the attribute name, and the value is a list of values that represent the attribute value for each raster.

Attribute values can also be collected from the STAC items automatically using the STAC item metadata information. To do this, specify the STAC item property name for the attribute of interest as key-value pairs (attribute display name: STAC item property name).

{
"Name": "id",
"Sensor": "platform",
"StdTime": "datetime",
"Cloud Cover": "eo:cloud_cover",
"Spatial Reference": "proj:epsg",
"Extent": "bbox"
}

Remarque :

If no Geometry key is specified, it will be automatically added for each raster in the RasterCollection object based on its STAC item's geometry property and will use a spatial reference as follows: "Spatial Reference": {"wkid": 4326}.

Dictionary
request_params

The parameters of the STAC catalog or item request.

Specify the requests.post() or requests.get() method parameters and values in dictionary format.

{
"verify": False,
"headers": {"Authorization": "Bearer access_token_string"}
}
Dictionary
context

Additional properties that will be used to control the creation of the object.

The dictionary supports the assetManagement and processingTemplate keys.

The assetManagement key specifies how to manage and select assets for the RasterCollection object. If multiple assets are selected, the collection will be composed of multiband rasters from those selected asset types. The value can be a list, string, or dictionary.

When working with individual assets, the asset key can be specified directly, for example, "B02" or {"key": "B02"}, or as a list. Each item in the list represents an asset key or identifier. Items in the list can be strings representing the asset key directly, or dictionaries providing additional details for locating the asset.

If the value of the assetManagement key is a dictionary, the following keys are supported:

  • key—A string representing the unique identifier for an asset, for example, "red".
  • path—A list representing the hierarchy of keys to navigate to the asset, for example, ["alternate", "s3"].
  • hrefKey—A string representing the key to access the asset URL, for example, "msft:https-url". If this value is different from the default href key, specify it here.

Examples:

{
    "assetManagement": [
        "red",
        "blue"
    ]
}
{
    "assetManagement": {
       "key": "tasmin",
       "hrefKey": "msft:https-url"
    }
}
{
    "assetManagement": [
       {"key": "TRAD",
        "path": ["alternate", "s3"]},
       {"key": "DRAD", 
        "path": ["alternate", "s3"]}
    ]
}

The processingTemplate key specifies the processing template that will be applied to the individual rasters in the collection. This is supported for selected collections and raster types. For more information about collections and raster types, see Satellite sensor raster types. The default for supported raster types is "Multiband"; otherwise, it's None.

Example:

{
    "processingTemplate": "Surface Reflectance"
}
Dictionary
Valeur renvoyée
Type de donnéesExplication
RasterCollection

A new instance of this class is returned

Use the GetSTACInfo function to gather necessary STAC information, which can then be used to create Raster objects with this method.

getFieldValues (field_name, {max_count})
ParamètreExplicationType de données
field_name

The name of the field from which to extract values.

String
max_count

An integer that specifies the maximum number of field values to be returned. The values will be returned in the order that the raster items are ordered in the collection. If no value is specified, all the field values for the given field will be returned.

(La valeur par défaut est None)

Integer
Valeur renvoyée
Type de donnéesExplication
String

The list of field values for the specified field name.

groupBy (field_name)
ParamètreExplicationType de données
field_name

The name of the field. Items with the same field values will be grouped together.

String
Valeur renvoyée
Type de donnéesExplication
Dictionary

A dictionary that contains the grouped raster collections. The dictionary key is a field value associated with the field name that was used to define the grouping. The dictionary value is a raster collection in which the field name contains the same field value.

majority ({ignore_nodata}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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.

(La valeur par défaut est 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.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the most frequently occurring pixel values for that band across all items in the raster collection.

map (func)
ParamètreExplicationType de données
func

The Python function to map over the raster collection. The return value of the function must be a dictionary in which one of the keys is raster. For example, {"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
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The raster collection in which each item contains the raster with the function applied and the attributes attached.

max ({ignore_nodata}, extent_type, cellsize_type)
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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.

(La valeur par défaut est 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.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the maximum pixel values for that band across all rasters in the raster collection.

mean ({ignore_nodata}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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.

(La valeur par défaut est 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.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the average pixel values for that band across all rasters in the raster collection.

median ({ignore_nodata}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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.

(La valeur par défaut est 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.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the median pixel values for that band across all rasters in the raster collection.

merge (collection2)
ParamètreExplicationType de données
collection2

The raster collection to be merged.

RasterCollection
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The merged raster collection.

min ({ignore_nodata}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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.

(La valeur par défaut est 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.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the lowest pixel values for that band across all rasters in the raster collection.

mosaic ({mosaic_method})
ParamètreExplicationType de données
mosaic_method

The method that will be used for overlapping areas between adjacent raster items. Mosaic method options include the following:

  • FIRSTThe pixel value from the first raster that is overlapping will be determined.
  • LASTThe pixel value from the last raster that is overlapping will be determined.
  • MEANThe average pixel value from the two rasters that are overlapping will be determined.
  • MINIMUMThe lower pixel value from the two raster datasets that are overlapping will be determined.
  • MAXIMUMThe higher pixel value from the two raster datasets that are overlapping will be determined.
  • SUMThe sum of pixel values from the two rasters that are overlapping will be determined.

For more information about mosaic methods, see Displaying overlapping imagery.

(La valeur par défaut est First)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster dataset with the mosaicked raster items from the raster collection.

qualityMosaic (quality_rc_or_list, {statistic_type})
ParamètreExplicationType de données
quality_rc_or_list

The raster collection or list of rasters to be used as quality indicators.

For example, Landsat 8's Band 1 is the Coastal/Aerosol band, which can be used to estimate the concentration of fine aerosol particles such as smoke and haze in the atmosphere. For a collection of Landsat 8 images, use the selectBands method to return a RasterCollection object containing only Band 1 from each raster item. The number of raster items in the quality_rc_or_list must match the number of raster items in the raster collection to be mosaicked.

RasterCollection
statistic_type

The statistic used to compare the input collection or list of quality rasters.

  • MAXThe highest pixel value in the input quality rasters will be the pixel value in the output raster. This is the default.
  • MEDIANThe median pixel value in the input quality rasters will be the pixel value in the output raster.
  • MINThe minimum pixel value in the input quality rasters will be the pixel value in the output raster.

For example, to mosaic the input raster collection such that those with the lowest aerosol content are on top, use the MIN statistic type.

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster dataset with the mosaicked raster items from the raster collection.

reduce (func, {func_args})
ParamètreExplicationType de données
func
[func,...]

The function used to reduce the raster collection. This argument also accepts a custom reducer function.

(La valeur par défaut est None)

String
func_args

A dictionary that contains additional parameters for the reducer function.

rc = RasterCollection("<data path>")
max_raster = rc.reduce(func=Max, func_args={'extent_type': 'UnionOf', 
                                            'cellsize_type': 'MinOf', 
                                            'ignore_nodata': True, 
                                            'process_as_multiband': True})

(La valeur par défaut est None)

Dictionary
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters that satisfy the reducer method.

selectBands (band_ids_or_names)
ParamètreExplicationType de données
band_ids_or_names
[band_ids_or_names,...]

The names or index numbers of bands to be included in the returned raster items. This can be specified with a single string, integer, or a list of strings or integers.

Object
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The collection of rasters containing only the selected bands.

sort (field_name, {ascending})
ParamètreExplicationType de données
field_name

The name of the field to use for sorting.

String
ascending

Specifies whether to sort in ascending or descending order.

(La valeur par défaut est True)

Boolean
Valeur renvoyée
Type de donnéesExplication
RasterCollection

The sorted collection of raster items.

std ({ignore_nodata}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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.

(La valeur par défaut est 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.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the standard deviation pixel values for that band across all rasters in the raster collection.

sum ({ignore_nodata}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
ignore_nodata
[ignore_nodata,...]

Specifies whether NoData values are ignored.

(La valeur par défaut est 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
Valeur renvoyée
Type de donnéesExplication
Raster

The raster in which each band contains the sum of pixel values for that band across all rasters in the raster collection.

summarizeField (field_name, {summary_type})
ParamètreExplicationType de données
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.

(La valeur par défaut est ALL)

String
Valeur renvoyée
Type de donnéesExplication
Dictionary

A dictionary of the summary methods and values.

toMultidimensionalRaster (variable_field_name, dimension_field_names)
ParamètreExplicationType de données
variable_field_name

The name of the field that contains the variable names.

String
dimension_field_names
[dimension_field_names,...]

The name of the field or fields that contains the dimension names. This can be specified as a single string or a list of strings.

For time-related dimensions, the field name must match one of the following to be recognized as a time field: StdTime, Date, Time, or AcquisitionDate. For nontime-related dimensions, the values in those fields must be type Double. If there are two or more dimensions, use a comma to separate the fields (for example, dimension_field_names = ["Time", "Depth"]).

String
Valeur renvoyée
Type de donnéesExplication
Raster

The multidimensional raster object. Each item in the raster collection is a slice in the multidimensional raster.

Exemple de code

RasterCollection example 1 (Python window)

Create a raster collection from a mosaic dataset and filters the collection by date.

# 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 example 2 (Python window)

Create a raster collection from a mosaic dataset and filter the collection by geometry.

# 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 example 3 (stand-alone script)

Create a raster collection from a mosaic dataset and filter the collection by an attribute.

# 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 example 4 (Python window)

Create a raster collection from a list of rasters depicting NDVI and return the maximum NDVI values for each pixel across the collection.

# 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 example 5 (Python window)

Map a Python function over a raster collection to generate a new collection.

# 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')
RasterCollection example 6 (Python window)

Create a RasterCollection object from a SpatioTemporal Asset Catalog (STAC) API search query.

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

# 1) Creates a raster collection from Earth Search STAC API

# Defining query parameters
query_params = {
    "collections": ["sentinel-2-l2a"],
    "bbox": [-110, 39.5, -105, 40.5],
    "query": {"eo:cloud_cover": {"lt": 10}},
    "datetime": "2020-10-05T00:00:00Z/2020-10-10T12:31:12Z",
    "limit": 5,
}
 
# Define attribute dictionary using the STAC Item properties
attribute_dict = {
    "Name": "id",
    "Platform": "platform",
    "StdTime": "datetime",
    "Cloud Cover": "eo:cloud_cover",
    "Spatial Reference": "proj:epsg",
    "Extent": "bbox",
}
 
# Construct a collection from the Sentinel-2 L2A data accesible through Earth Search STAC API

sentinel_2_rc = RasterCollection.fromSTACAPI(
    stac_api="https://earth-search.aws.element84.com/v1",
    query=query_params,
    attribute_dict=attribute_dict,
)

# Filter the collection further to work with data only from the Sentinel-2A satellite
filtered_rc = sentinel_2_rc.filterByAttribute("Platform", "EQUALS", "sentinel-2a")

# 2) Creates a raster collection from Planetray computer STAC API

# Defining query parameters
query_params = {
    "collections": ["naip"],
    "bbox": [-122.2751, 47.5469, -121.9613, 47.7458],
    "datetime": "2018-12-01/2020-12-31",
    "limit": 5,
}
 
# Define attribute dictionary using the STAC Item properties
attribute_dict = {
    "Name": "id",
    "GSD": "gsd",
    "StdTime": "datetime",
    "State": "naip:state",
    "Spatial Reference": "proj:epsg",
    "Extent": "bbox",
}
 
# Construct a collection from the NAIP data accesible through Planetary Computer STAC API
naip_rc = RasterCollection.fromSTACAPI(
    stac_api="https://planetarycomputer.microsoft.com/api/stac/v1",
    query=query_params,
    attribute_dict=attribute_dict,
)
 
# Define a Python function to map grayscale raster function to the whole collection
def grayscale(item):
    # Get the raster object from the item
    raster = item["Raster"]
    # Get the raster objects for the NIR and Red bands
    gray_raster = Grayscale(raster)
    # Compute the index
    return {
        "raster": gray_raster,
        "name": f"gray_{item['Name']}",
        "StdTime": item["StdTime"],
    }
 
# apply grayscale function to each raster item in the raster collection using the map function
gray_rc = naip_rc.map(grayscale)
 
# work with the first raster in the grayscale collection
gray_raster_1 = gray_rc[0]["Raster"]

# 3) Creates a raster collection from the Landsat-9 C2-L2 data accesible through

# Digital Earth Africa STAC API (with custom asset selection) - Requires acs (AIO object).

landsat_dea_acs = AIO(r"C:\acsfiles\s3_dea_landsat.acs")

landsat_dea_rc = RasterCollection.fromSTACAPI(
      stac_api="https://explorer.digitalearth.africa/stac",
      query={
	"collections": ["ls9_sr"],
	"bbox": [
	        25.982987096443583,
	        29.249912751222965,
	        28.30879111403085,
	        31.348538968581714,
	      ],
	     "datetime": "2023-12-25/2023-12-31",
	},
	attribute_dict={
	    "Name": "id",
	    "Sensor": "platform",
	    "Cloud Cover": "eo:cloud_cover",
	    "Row": "landsat:wrs_row",
	    "Path": "landsat:wrs_path",
	},
	context={"assetManagement": ["SR_B4", "SR_B3", "SR_B2"]}, # rgb
)
RasterCollection example 7 (Python window)

Create a RasterCollection object from a static SpatioTemporal Asset Catalog (STAC) catalog.

# Import system modules
from arcpy.ia import *

# 1) Creates a raster collection from Maxar STAC (Static Catalog)

# Define attribute dictionary using the STAC Item properties
attribute_dict = {
    "Name": "id",
    "Platform": "platform",
    "StdTime": "datetime",
    "Data Area": "tile:data_area",
    "Clouds Percent": "tile:clouds_percent",
    "Spatial Reference": "proj:epsg",
}

# Construct a collection from Maxar STAC

     maxar_rc = RasterCollection.fromSTACCatalog(
     stac_catalog="https://maxar-opendata.s3.amazonaws.com/events/Emilia-Romagna-Italy-flooding-may23/ard/acquisition_collections/103005009DF96A00_collection.json",
     attribute_dict=attribute_dict,
)

# Filter the collection further to only work with data that has tile area less than 15 square kilometer

filtered_rc =maxar_rc.filterByAttribute("Data Area", "LESS_THAN", 15)

# 2) Creates a raster collection from New Zealand Imagery STAC (Static Catalog)

# Define attribute dictionary using the STAC Item properties
attribute_dict = {
   "Name": "id",
   "Start StdTime": "start_datetime",
   "End StdTime": "end_datetime",
   "Extent": "bbox",
}

# Construct a collection from New Zealand Imagery STAC

     nz_rc = RasterCollection.fromSTACCatalog(
     stac_catalog="https://nz-imagery.s3-ap-southeast-2.amazonaws.com/tasman/tasman_snc30002_2002_0.75m/rgb/2193/collection.json",
     attribute_dict=attribute_dict,
)

# Define a Python function to map grayscale raster function to the whole collection

def grayscale(item):
	# Get the raster object from the item
	raster = item["Raster"]

	# Get the raster objects for the NIR and Red bands
	gray_raster = Grayscale(raster)

	# Compute the index
	return {
		"raster": gray_raster,
		"name": f"gray_{item['Name']}",
		"StdTime": item["Start StdTime"],
		}

# apply grayscale function to each raster item in the raster collection using the map function

gray_rc = nz_rc.map(grayscale)

# work with the first raster in the grayscale collection

gray_raster_1 = gray_rc[8]["Raster"]

#3) Creates a raster collection from UMBRA STAC (with custom asset selection)

umbra_rc = RasterCollection.fromSTACCatalog(
stac_catalog="https://s3.us-west-2.amazonaws.com/umbra-open-data-catalog/stac/2024/2024-02/2024-02-19/catalog.json",
       attribute_dict={
	"Name": "id",
	"Sensor": "platform",
	"StdTime": "datetime",
	"Polarizations": "sar:polarizations",
	"Extent": "bbox",
	},
	context={"assetManagement": ["GEC"]},
	)