Raster Zonal Statistics

Extracts zonal statistics from a raster image.


Description

A processing block that computes zonal statistics for an input image or zoning map.

See this block on the marketplace.

How it works

The output is a GeoJSON file for each input image. The data.json file of the output will also be populated with the computed statistics. For each band of the input image, statistics are computed, and the name of the variable follows the convention [band_number]_[stats_name]. In addition, another file results_merged.geojson is generated, which contains the results of all images and zones as a single file. Note that this file is not exposed as an output capability.

This block is particularly useful to extract information from raster data. For instance, you can compute the average NDVI values in certain fields, based on a set of NDVI raster files and on the vector files defining the geometry of each individual field.

ParameterOverview
statsarray of strings / required
The allowed strings in an array:
  • min
  • max
  • mean
  • sum
  • std
  • median
  • majority
  • minority
  • unique
  • range
  • nodata
  • percentile\_\[0-100\]
  • count
The default value is ["min", "max", "mean", "median", "std", "count"].
zonesarray of objects
An array of Polygon EPSG:4326 geometry, used as zones to calculate statistics for. The default value is [] — it'll use the overall image geometry as only zone.
zones_attribute_idstring
A unique identifier of the geometry to add to the output of the GeoJSON file. The default value is "zone_id". Will use a sequential value (0 to length of zones - 1) if the key is not set in Feature.

A list of Features is what makes up a FeatureCollection as defined by the GeoJSON format.

Zones input example
[
  {
    "type": "Feature",
    "properties": {
      "zone_id": "zone_A"
    },
    "geometry": {
      "type": "Polygon",
      "coordinates": [
        [
          [13.360834121704102, 52.51846674522954],
          [13.366670608520508, 52.51846674522954],
          [13.366670608520508, 52.52060806001903],
          [13.360834121704102, 52.52060806001903],
          [13.360834121704102, 52.51846674522954]
        ]
      ]
    }
  },
  {
    "type": "Feature",
    "properties": {
      "zone_id": "zone_B"
    },
    "geometry": {
      "type": "Polygon",
      "coordinates": [
        [
          [13.365554809570312, 52.51481060072091],
          [13.37087631225586, 52.51481060072091],
          [13.37087631225586, 52.51705655410405],
          [13.365554809570312, 52.51705655410405],
          [13.365554809570312, 52.51481060072091]
        ]
      ]
    }
  }
]
FeatureCollection output example
{
  "type": "FeatureCollection",
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::3857"
    }
  },
  "features": [
    {
      "type": "Feature",
      "properties": {
        "zone_id": "A",
        "1_mean": 0,
        "2_mean": 0,
        "3_mean": 0,
        "4_mean": 0
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-833988.222014860599302, 4830765.350448431447148],
            [-833047.463339990237728, 4830765.350448431447148],
            [-833091.561402874765918, 4829692.297584908083081],
            [-834002.921369155403227, 4829751.095002084039152],
            [-833988.222014860599302, 4830765.350448431447148]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "zone_id": "B",
        "1_mean": 0,
        "2_mean": 0,
        "3_mean": 0,
        "4_mean": 0
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-831533.429847621009685, 4828104.767321062274277],
            [-830283.984732558950782, 4827987.172486702911556],
            [-830504.475046981591731, 4827208.10670907702297],
            [-831695.12274486431852, 4827384.498960615135729],
            [-831533.429847621009685, 4828104.767321062274277]
          ]
        ]
      }
    }
  ]
}

You can make use of geojson.io to generate Feature and FeatureCollection.

Example

An example using the data block SPOT 6/7 Display (Streaming) and calculating zonal statistics, mean or average, on the whole AOI.

{
  "oneatlas-spot-aoiclipped:1": {
    "bbox": [13.405215963721279, 52.48480326228838, 13.4388092905283, 52.505278605259086],
    "ids": null,
    "time": "2018-01-01T00:00:00+00:00/2019-12-31T23:59:59+00:00",
    "limit": 1,
    "zoom_level": 17,
    "time_series": null,
    "panchromatic_band": false
  },
  "zonal-statistics:1": {
    "stats": ["mean"]
  }
}

Capabilities

Input

Output

To know more please check the block capabilities specifications.