Geospatial Modelling Environment

isectpolyrst (Intersect Polygons With Raster)

Creates summaries for each polygon based on the values in a raster layer


This tool summarizes the raster cell values that are contained by a polygon. The output consists of summary fields that are added to the polygon attribute table. It processes thematic (i.e. categorical) and continuous rasters in different ways. For thematic rasters, a new field is added for each unique value in the raster and is populated with either a count of the number of cells of each raster value within that polygon, or the proportion of cells of each raster value. For continuous rasters a statistical summary is produced (the mean, median, minimum, maximum, standard deviation, count, and the 95% quantiles).

Polygons are processed sequentially, so are not affected in any way by overlapping polygons (in contrast to related tools in ArcGIS). This means that it can take a considerable time to process many polygons.

This tool cannot distinguish between thematic and categorical rasters automatically. By default it assumes the raster represents continuous data, so if the raster is a thematic raster you must explicitly use the ‘thematic=TRUE’ option.

NoData cells are ignored. Therefore, if the polygon contains NoData cells this may influence the accuracy of the statistical summary. It is highly recommended you ensure that raster data exists for the entire area covered by the polygons. By default, any polygons that are entirely or partially outside of the extent of the raster will not be processed – they will be coded with NoData values (-2147483648) so should be easily identifiable. This behaviour is a precaution against potentially biased estimates, but can be overridden using the allowpartialoverlap parameter. Setting this parameter to TRUE will force all polygons to be processed, even if they only partially overlap the extent of the raster dataset.

Note that this single command provides the same functionality as both the ‘Zonal Statistics ++’ and ‘Thematic Raster Summary’ tools in HawthsTools.

Recent changes to the interface with R mean that the median and quantiles options (calculated of medquant=TRUE) will tend to run quite slowly. I am working on resolving this speed issue for a future update.


isectpolyrst(in, raster, prefix, [thematic], [proportion], [metrics], [allowpartialoverlap], [medquant], [where]);

inthe input polygon data source
rasterthe input raster data source
prefixa short prefix to use in the summary statistic fields that are added, which end with MN, MIN, MAX, STD, CNT, MED for continuous raster data, and V# for thematic raster data where # is each of the unique cell values. The prefix should be no longer than 6 characters, and should be related in some way to the raster dataset.
[thematic](TRUE/FALSE) controls whether the raster should be treated as a thematic (categorical) raster (default=FALSE)
[proportion](TRUE/FALSE) only applies to thematic rasters: records the proportion of the polygon in each cell value rather than the area of the polygon (default=FALSE)
[metrics]the statistical metric(s) to calculate, expressed as a single value (e.g. “MIN”) or as a vector of metrics (e.g. c(“MN”,”STD”,”CNT”)); options are MN/MEAN, MIN, MAX, STD, SUM, CNT, MED, QUPP, QLOW (see help for details)
[allowpartialoverlap](TRUE/FALSE) if TRUE, will process polygons that only partially overlap the extent of the raster dataset (default=FALSE)
[medquant](TRUE/FALSE) controls whether the R derived median and quantiles are included in the statistical summary statistics (default=FALSE)
[where]the selection statement that will be applied to the feature data source to identify a subset of features to process (see full Help documentation for further details)


isectpolyrst(in=”C:datafields.shp”, raster=”C:datalandcov”, prefix=”LCOV”, thematic=TRUE);

isectpolyrst(in=”C:dataplots.shp”, raster=”C:datalandcov”, prefix=”LCOV”, thematic=TRUE, proportion=TRUE);

isectpolyrst(in=”C:dataparcels.shp”, raster=”C:datadem”, prefix=”DEM”);


Please consider making a purchase to support the continued development of these tools  Read more...

Tips on how to use this interface efficiently 


Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn