Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
podcast
Filter by Categories
ArcGIS Pro
GDAL
GeoJson
Map
Python
QGIS
Uncategorized

Raster Value into Polygon Attribute

How to Extract a Raster Value into Polygon Attribute

To extract raster values into polygon attributes, you can use the GIS software of your choice, such as QGIS or ArcGIS. In this example, I’ll provide steps for using QGIS, which is an open-source GIS software:

Want to stay ahead of the geospatial curve? Listen to our podcast!

  1. Install QGIS: Download and install QGIS from the official website: https://www.qgis.org/en/site/forusers/download.html.
  2. Load raster and vector data: Open QGIS and import both your raster and vector data (shapefile or GeoJSON) into the project. To do this, click on “Layer” > “Add Layer” > “Add Raster Layer” for raster data and “Layer” > “Add Layer” > “Add Vector Layer” for vector data.
  3. Compute Zonal Statistics: click on “Raster” > “Zonal Statistics” > “Zonal statistics” to open the Zonal Statistics dialog.
  4. Configure Zonal Statistics parameters: In the Zonal Statistics dialog, select your vector layer (polygon) as the “Input vector layer” and your raster layer as the “Raster layer.” Choose the attribute prefix (e.g., “raster_”) and select the statistics you want to calculate (e.g., “Mean”).
  5. Run Zonal Statistics: Click “Run” to start the Zonal Statistics process. This will calculate the specified statistics for each polygon using the raster values and add them as new attributes in the polygon layer.
  6. Check the results: Open the attribute table of your polygon layer by right-clicking the layer in the Layers panel and selecting “Open Attribute Table.” You should see new columns with the raster-derived statistics.

Now, you’ve successfully extracted raster values into polygon attributes. You can save the updated vector layer as a new file by right-clicking the layer and selecting “Export” > “Save Features As…” and choosing your desired format (e.g., shapefile or GeoJSON).

What are Zonal Statistics?

In the context of GIS, Zonal Statistics refers to the process of calculating statistical values based on the spatial relationship between a raster dataset and a set of vector polygons (zones). The term “zonal” implies that the analysis is done for each zone, which is represented by a polygon, using the underlying raster data.

The raster dataset typically contains continuous or categorical data, such as elevation, temperature, or land use, and each raster cell has a specific value. The vector polygon layer represents zones or areas of interest, such as administrative boundaries, land parcels, or habitat areas.

When performing zonal statistics, the GIS software calculates various statistics (such as mean, median, sum, minimum, maximum, range, standard deviation, etc.) of the raster values within each polygon zone. The statistics are then assigned as attributes to the corresponding polygons.

This process allows for the extraction of information from the raster dataset that is relevant to each zone. By doing so, zonal statistics can help in understanding spatial patterns, identifying trends, or supporting decision-making processes in various fields, including environmental management, urban planning, and agriculture.

Are Zonal Statistics calculated on all of the possible bands within a raster?

By default, zonal statistics are calculated on the single-band raster or the active band of a multi-band raster. However, in some GIS software, you can choose to calculate zonal statistics for each band of a multi-band raster separately.

In QGIS, for instance, the default Zonal Statistics plugin works on single-band rasters or the active band of a multi-band raster. If you want to calculate zonal statistics for each band of a multi-band raster, you can use the following workaround:

  1. Split the multi-band raster into separate single-band rasters. You can use the “Raster” > “Conversion” > “Translate (Convert Format)” tool to convert each band to a separate raster file. In the “Translate” dialog, select the input raster, choose the output file format, and set the “Band” option to the desired band number.
  2. Calculate zonal statistics for each single-band raster using the Zonal Statistics plugin, as described in the previous answer. Make sure to use a unique attribute prefix for each raster to distinguish the statistics from different bands.
  3. Merge the zonal statistics results from each single-band raster into the polygon layer’s attribute table.

In ArcGIS, the “Zonal Statistics as Table” tool allows you to calculate zonal statistics for all bands of a multi-band raster at once. In the tool’s parameters, set “ALL” as the value for the “Raster band(s) to process” option. This will calculate zonal statistics for each band and append them to the output table with a suffix indicating the band number.

Please note that not all GIS software may have built-in support for calculating zonal statistics on all bands of a multi-band raster. In such cases, you might need to find a plugin or script to achieve this, or manually process each band separately as described above.

About the Author
I'm Daniel O'Donohue, the voice and creator behind The MapScaping Podcast ( A podcast for the geospatial community ). With a professional background as a geospatial specialist, I've spent years harnessing the power of spatial to unravel the complexities of our world, one layer at a time.

Leave a Reply