Skip to main content
Solved

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

  • July 6, 2017
  • 2 replies
  • 149 views

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.

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.

2 replies

jdh
Contributor
Forum|alt.badge.img+40
  • 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.