Skip to main content
Solved

Saving an attribute table separately from a raster or shapefile

  • October 10, 2019
  • 4 replies
  • 55 views

wolters
Contributor
Forum|alt.badge.img+6

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.

 

Best answer by wolters

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • October 10, 2019

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?

 


wolters
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • 26 replies
  • Best Answer
  • October 10, 2019

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


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • October 10, 2019
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.

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • October 10, 2019

@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