Skip to main content
Released

Spatial Statistics on Raster Data

Related products:Integrations
  • Jan 14, 2016 12:00 AM UTC
  • 12 replies
  • 158 views

Easy way to calculate statistics of rasters within polygon area's. Basic stats like min, mean and average of pixel values.

12 replies

jdh
Contributor
Forum|alt.badge.img+41
  • Contributor
  • Jan 14, 2016 7:13 PM UTC

A few years ago I created a ZonalStatistics custom transformer. I can't share it here, but the basic workflow was

  • clip the raster(s) by the polygons (which had a Zone Id)
  • PointCloudCombiner (grouped on Zone Id)
  • PointCloudCoercer (Individual Points)
  • CoordinateExtractor (Z value)
  • StatisticsCalculator
  • FeatureMerger back to the polygons

Coercing a Raster to a PointCloud was (and probably still is) orders of magnitude faster than using the RasterCellCoercer.


david_r
Celebrity
  • Jan 15, 2016 8:28 AM UTC

I can confirm that the RasterCellCoercer isn't very fast at all. Great idea to coerce the raster into a point cloud, thanks for the tip!


Forum|alt.badge.img
  • Jun 1, 2018 6:02 PM UTC
And add histogram too

 

 


fmelizard
Safer
Forum|alt.badge.img+22
  • Safer
  • Jun 2, 2018 8:50 PM UTC
How would you like the histogram output? One feature (row) per pixel value, having the pixel value, the band #, and the count?

 

 


fmelizard
Safer
Forum|alt.badge.img+22
  • Safer
  • Jun 2, 2018 8:52 PM UTC

Note that FME 2018.1 has a RasterStatisticsCalculator that will do the calculation for a whole raster. You'd still have to clip as per @jdh above, but the next 5 steps are replaced by just the RasterStatisticsCalculator.


jdh
Contributor
Forum|alt.badge.img+41
  • Contributor
  • Jun 4, 2018 2:46 PM UTC
Histogram would be awesome. My RasterHistogrammer custom transformer creates a compound list on the original raster

 

_band{}.histogram{}.value

 

_band{}.histogram{}.count

 

 

I think matching the statisticsCalculator format of [list name]{}.count|value as close as possible would be the way to go.

 

so maybe [list name]{}.band{}.value

 


maayke
Contributor
Forum|alt.badge.img+6
  • Contributor
  • Jun 8, 2018 8:20 AM UTC
The RasterStatisticsCalculator sounded very promising at first for this purpose, but when the polygon dataset I'm working with is very large, the transformer isn't working well for me. It would be really great to see an equivalent of Zonal Statistics in FME in a future version!

fmelizard
Safer
Forum|alt.badge.img+22
  • Safer
  • Jun 11, 2018 4:43 AM UTC
Would you mind sending your polygon dataset in to support@safe.com -- when you say it is large, do you mean you have a large #of polygons, or a few polygons that are large in size?

 

 


maayke
Contributor
Forum|alt.badge.img+6
  • Contributor
  • Sep 10, 2018 12:43 PM UTC

 

Hi @daleatsafe - thank you for your response and I'm sorry for the late reply. At the time we used QGIS instead, but now, a few months later, the problem reoccurred. I meant a large number of polygons! I've sent a sample of the data to the support team.

Forum|alt.badge.img
  • Oct 24, 2019 8:30 PM UTC

Hi, it's also needed to have a histogram functionality for both rasterstatistics and pointcloudstatistics!

 

 

For example, a pointcloud of where z component has to be ranged according to Count of unique z values should be easy to add. Its already possible to filter/range according to any Component, so the idea would simply be to come up with a solution for finding unique values within the pc component's

john_gis4
Contributor
Forum|alt.badge.img+13
  • Contributor
  • Mar 15, 2021 6:16 PM UTC

I am also looking for a way to get counts of cell values in a given raster (or better still a zone of a raster defined by a polygon or other raster).

For example, I have 3 values representing terrain categories in the source raster. For each polygon I need to find the count of cells for each category. This would be pretty straightforward in ArcGIS Spatial Analyst, but have struggled to find a way to do it in FME.

I would have thought it's just an extension to the RasterStatisticsCalculator to optionally output a list of cell values and their count.


LizAtSafe
Safer
Forum|alt.badge.img+26
  • Safer
  • Feb 12, 2025 7:50 PM UTC
Open→Released