Spatial Modeler Discussions

Gain, exchange, and share knowledge, or discuss topics with other Hexagon Geospatial Product pioneers and experts to get the most out of Hexagon Geospatial products.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 59
Registered: ‎04-19-2016
Accepted Solution

Zonal Attribute Function in Spatial Modeler

Hi there,

 

This may be a silly question, but I am building a complex model and need help.

 

My model creates a shapefile of polygons (segments), and a raster image of meaningful values. What I'd like to do is populate the polygons with the MEAN statistical value of the raster image values, within a new column in the attribute table.

 

Manually I can go to the Raster Tab -> Thematic -> Zonal Attributes to do the said analysis, however I'd like to find out if there is an approach to do this in the Spatial Modeler (through different operators), so that I can complete this analysis as part of my complex model?

 

Please help!

 

Thanks in advance!

 

Best Regards

 

Jens

 

 

Technical Evangelist
Posts: 157
Registered: ‎07-04-2016

Re: Zonal Attribute Function in Spatial Modeler

Dear Jens,

 

Below you can find an illustration of how you can add the MEAN statistical value of the raster image values within a new column in the attribute table.

 

ERDAS IMAGINE 2016 model.jpg

 

Also attaching the model.

 

Hope this will help.

 

 

 

Kind Regards,

Marina

 

 

Kind Regards,
Marina Vardovska
Hexagon Geospatial Support
Technical Evangelist
Posts: 1,121
Registered: ‎10-01-2015

Re: Zonal Attribute Function in Spatial Modeler

[ Edited ]

Excellent Model Marina.

 

This would be the equivalent using the new streaming features technology in ERDAS IMAGINE 2016:

 

Z_Mean.PNG

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Contributor
Posts: 59
Registered: ‎04-19-2016

Re: Zonal Attribute Function in Spatial Modeler

Hi Marina and Ian,

 

Marina thanks for the awesome response, I have implemented the suggested model and it has really helped! So thank you!

 

Ian, I am glad you added the workflow (ERDAS 2016), because I was having trouble with the background row being included into the attribute transfer, so the "Remove Background Row" is exactly what I needed. Thanks.

 

My 2 cents, if the zones exist in raster as an input, the process is 10x faster inputing the raster zones than shapefile zones, and then adding the zonal attribute to the raster and then converting the raster to shapefile.

 

Also, the zonal mean attribute's accuracy is higher when analysing zonal raster to class raster, than zonal shapefile to class raster (which is understandable since the shapefile has to be converted to a raster cell before the zonal statistic processing can take place). This is only the case if the zones are available as raster and shapefile.

 

Anyways thanks guys, you are flippin awesome.

 

Cheers

 

Jens 

Regular Visitor
Posts: 1
Registered: ‎02-20-2017

Re: Zonal Attribute Function in Spatial Modeler

Did you manage to change "ZonalMean" to reflect the input image name and band? I am trying rename attributes but am getting the same old ZonalMean attribute name and green check marks in the modeller.

 

Occasional Contributor
Posts: 9
Registered: ‎02-06-2018

Re: Zonal Attribute Function in Spatial Modeler

[ Edited ]

I like the simplicity of this model. However, it's not working for me (Imagine 2016) -- it just seem to run forever, with no error messages in the session log. Ditto Ian's version. The process is taking up a lot of CPU clicks, with the laptop's fan on continuously, so it seems to be doing something. There's nothing odd about the shapefile (about 600 features) and raster (continuous). I can post them to a Google Drive for testing if that helps. The only thing I can think of is that perhaps the shapefile has geographic coordinates while the raster is in Albers -- but since the vector layer is rasterized before zonal operations, I wouldn't have thought this would be an issue. Any ideas? It's such a fundamental operation: query raster values under vector-specified features. 

 

p.s., I just saw that the messages box says "No cell size specified. Using default size of 1 X 1 m.". Maybe that's the issue: the map area is the western US. 

Occasional Contributor
Posts: 9
Registered: ‎02-06-2018

Re: Zonal Attribute Function in Spatial Modeler

Update: Success! After the vector was reprojected to Albers, the vector input units were set to 30 m (the spatial resolution of the imagery from which it was vectorized), and a boundary set for the raster using the inquire box. I'm not sure where to find the set window/cell size/projection/AOI for the new spatial modeler, maybe it has be to done via the operators now. 

Technical Evangelist
Posts: 1,121
Registered: ‎10-01-2015

Re: Zonal Attribute Function in Spatial Modeler

Define Processing Area is the Operator you need for settign common processing area, etc. 

 

Cheers

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Occasional Contributor
Posts: 9
Registered: ‎02-06-2018

Re: Zonal Attribute Function in Spatial Modeler

[ Edited ]

Hi Ian, Thanks. I am still having issues with this. Applying the model (below, right) to the polygon shapefile to extract statistics from a binary (1-bit) thematic raster (forest/non-forest) I am getting strange values. For example, see the Rodeo-Chediski fire perimeter (below, left, selected polygon). The zonal mean model results in a value of 0.499 (about 50% forest vs non-forest) for this polygon. However, the interior is mostly forested (green) and remains so if you zoom in (this is not an artefact of interpolation in the view). Similar values are obtained for other features. I need to have confidence in these calculations, so I would be very grateful if you -- or anyone -- has any ideas on why this is happening, or what I am doing wrong. I can stage the files if necessary (I have attached the screen shot PNG since the inline image is probably unreadable). Thanks. --Mark

 

Screen Shot 2021-02-11 at 3.14.50 PM.png

Technical Evangelist
Posts: 1,121
Registered: ‎10-01-2015

Re: Zonal Attribute Function in Spatial Modeler

Hi Mark,

 

Other than this thread it has been a long time since we last talked. A long way from Cambridge and Nottingham!

 

Might be easiest to send me your data to play with. But one thing to check first - you have a Boundary set on the Vector Input as Raster operator. Are you sure that's not limiting the processing to a sub-area that might be 50-50 forest/non-forest? Or did you use the Inquire Box to try to put a limiting rectangle around the fire extent polygon?

 

Cheers

 

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial