Skip to main content
Solved

Extract average of interior values from a raster in the polygon with the same location XY from a shapefile


Hello,

On the one hand, I have a raster file which represents ground elevation. On the other hand I have a file from PostGIS with a shape_polygon geometry, which represents outlines of buildings. I'd like to create a new attribute per building in which there would be the average of all interiors cell values.

Any ideas ?

Thanks a lot,

JJ

Best answer by jdh

This is a case where dealing with PointClouds rather than rasters is much more efficient.

 

 

Add a counter to get an unique id on your buildings if they don't already have them. Set a NoDataValue on the Raster if it doesn't already have one.

Use a GeometryExtractor on the building to store the geometry as an attribute.

Clip the raster by buildings, with merge attributes set to yes.

Send the Clipped rasters to a PointCloudCombiner, grouping by the UniqueID

Use the PointCloudStatisticsCalculator to get the Mean of the z component.

Use a GeometryReplacer to restore the original building geometry.

You should now have your buildings with an addition attribute called z.mean.

View original
Did this help you find an answer to your question?

2 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • July 6, 2017

This is a case where dealing with PointClouds rather than rasters is much more efficient.

 

 

Add a counter to get an unique id on your buildings if they don't already have them. Set a NoDataValue on the Raster if it doesn't already have one.

Use a GeometryExtractor on the building to store the geometry as an attribute.

Clip the raster by buildings, with merge attributes set to yes.

Send the Clipped rasters to a PointCloudCombiner, grouping by the UniqueID

Use the PointCloudStatisticsCalculator to get the Mean of the z component.

Use a GeometryReplacer to restore the original building geometry.

You should now have your buildings with an addition attribute called z.mean.


  • Author
  • July 6, 2017

It works correctly, thank you !

 

I wasn't on the right track.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings