Skip to main content

Hi all,

 

I am trying to calculate the surface area of different LULC classes. I have to do this for very many different polygon areas, using the Rastertopolygoncoercer takes too much time, so I do this by counting the pixels of specific values, and then calculating the surface area based on the pixel size of my raster.

 

Ordinarily I would do this with the ArcGIS Zonal Statistics function for rasters with the "count" functionality and be done with it. This does not seem to exist in FME, the RasterStatisticsCalculator misses this feature (and only that feature, strangely). So what I do instead is per class, replacing the cell values with 1 (and all others 0), and then calculating the "SUM" with FME's RasterStatisticsCalculator.

 

It gives me the result I want (in a cumbersome roundabout way) but then, I want to save the attribute table separately from the raster. Because when I do a rasterstatistics of the individual rasters (which are clipped with the polygons, and the attributes of the polygons are merged so I know which area fits with which "SUM" down the line), FME wants to save the data as a raster, e.g. a Geotiff. But then the calculated Rasterstatistics aren't saved and are lost. I can see the attribute table I want when I connect the final step to a FME inspector port.

 

My question therefore is, how do I separate the attribute table from the raster, so I can save this separately in e.g. a table, CSV or Excel document? I couldn't find specific options in the GEOTIFF writer. Simply connecting an Excel writer won't work. Or should I use some other type of raster? Or do I copy it from the FME inspector somehow? In ArcGIS, there is the possiblity to add an attribute table to a raster.

 

Thank you all for your help.

 

If you can see the attribute table, I'm not sure why you can't just write that straight to a csv or excel file?

 


Solved my own question, this can be done using the rasterpropertyextractor and then saving as a CSV


For the zonal statistics part, it may be faster to clip the raster, convert to point cloud (PointCloudCombiner), PointCloudSplitter (unique Z), PointCloudPropertyExtractor (num points), calculate area (numpoints*cell size)

 

You can then merge them back onto the original polygon, or otherwise structure the data to write out a csv.

 

 

If you wanted other statistics, after the pointCloudCombiner you could use the PointCloudStatisticsCalculator instead. You would still need the property extractor to get the number of points.

@takashi has also posted some python that can be used in a pythoncaller which will allow calculation of raster statistics including count

https://knowledge.safe.com/questions/38000/python-fme-objects-api-for-raster-manipulation.html


Reply