Hexagon Geospatial
MENU

Spatial Modeler

Discuss topics with other Hexagon Geospatial Product pioneers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 83
Registered: ‎07-17-2017
Accepted Solution

How to build a generalized raster with lower resolution than the input raster?

Hi everybody,

 

I have a raster with a resolution of 1x1 meter. What I want to achieve is a raster with a resolution of 20x20 meters where every cell contains the sum of the underlaying 1x1 meter cell values  (see attachment).

How can I build this workflow in spatial modeler?

 

Thanks for any hints!

Marisa

 

Highlighted
Frequent Contributor
Posts: 153
Registered: ‎10-27-2015

Re: How to build a generalized raster with lower resolution than the input raster?

I believe there is no straight one click solution to this and you have to make a new resolution zones and then use zonal sum function and turn that then to new lower resolution raster where each zone represents single new pixel. Degrade, Resample and other tools for this task makes no sum of pixels but some other interpolation.

 

Extremely good excersice to someone make a model for this - or does such already exist somewhere in spatial/analytical receipes??

 

http://community.hexagongeospatial.com/t5/Spatial-Recipes/tkb-p/KS_SpatialModeler_AnalyticalRecipes

 

 

timo

 

ps. In generally I think this kind of functionality requests are just what is needed in this community - especially if answers come. Maybe there even exist a business to someone make thse models and publish them as a service in M.Apps or just pure models. What I hope from this user community is that if someone solves a problem like this it will be sharer/published to others and if not for free then it should be made available for selling service via M.Apps or something like that. It does not make sense that we all solve same problems independently while sharing might save someone else's back.  Just this makes tool more powerfull and capable - we are not limited what Hexagon can publish but we users can make tools for each other too.

Technical Evangelist
Posts: 599
Registered: ‎10-01-2015

Re: How to build a generalized raster with lower resolution than the input raster?

[ Edited ]

Hi Marisa,

 

I really dislike even-numbered moving window processes! It makes life complicated. :-)

 

But anyway - the attached model takes a 1m input image and turns it into a 20m pixel size image representing the sum of the 20 x 20 pixels that fall under the footprint of the output pixel. I created it using ERDAS IMAGINE 2018, but it should run under ERDAS IMAGINE 2016 v16.1 as well. Hope it helps out. I'll hopefully find time to write this up as a Spatial Recipe since it's an excellent example of why and where to use the Warp operator

 

generalize.PNG

 

 

 

 

 

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Frequent Contributor
Posts: 153
Registered: ‎10-27-2015

Re: How to build a generalized raster with lower resolution than the input raster?

Not bad Ian - once again - I thought that with Focal Sum you end up getting a new value for each original higher resolution pixel and thought that Zonal is the only way do it. Clearly I need to study bit more what that Warp tool makes - it looks pretty advanced function.

Regular Contributor
Posts: 196
Registered: ‎11-16-2015

Re: How to build a generalized raster with lower resolution than the input raster?

I'm with you Timo; I need to figure out exactly what to do with the Warp tool. I don't think it does what I think it does...!

Technical Evangelist
Posts: 599
Registered: ‎10-01-2015

Re: How to build a generalized raster with lower resolution than the input raster?

It's the combination of a Warp operator and Define Processing Area (with pixel size set to 20x the input pixel size) that does the heavy lifting for you.

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Frequent Contributor
Posts: 153
Registered: ‎10-27-2015

Re: How to build a generalized raster with lower resolution than the input raster?

[ Edited ]

I agree with Ian that moving focal windows may not be the smartest in remote sensing but for certain raster GIS tasks this is a brilliant feature. Now need was Focal Sum but someone might need Mean, Median, Min, Max etc. So with this Focal - Warp - Define Processing area process flow you have clearly generated a new functionality in Imagine and proven once again power of Spatial Modeller. Data degrading with control how new pixel value is generated - that is a good new thing that most likely never existed in Imagine before.

 

Spatial Modeller is a brilliant tool and we users must learn more about it to benefit more. This was a great new sample from Ian and old horses like me and Johnnie have now perhapsh learned something new.

 

Thanks Ian

 

Timo - the one who is learning Iterator operator just now

Frequent Contributor
Posts: 83
Registered: ‎07-17-2017

Re: How to build a generalized raster with lower resolution than the input raster?

Hi Ian,

 

thanks a lot for helping me that fast! I didn't expect to get a ready to use spatial model right away! :-)

The output looks nice but I'm a bit confused concerning the pixel values. It doesn't seem to me like they actually represent the plain sum of the pixel values of the input raster. 

I'm not an expert in raster analyses and as Timo noticed correctly I need it for some GIS task. In my case I need to get the sum of people living within a 20x20m raster or another cell size. In the first step I convert my vector point layer (containing houses) into a 1x1 raster with the "Vector Input As raster " Operator setting the BackgroundValue to 0|false and choosing the attribute "residents" (Integer values between 1 and 8). When I use your model and replace the "raster Input" operator with the explained vector conversion the output image is an interpolated raster I guess.

Did I miss something or used your model for the wrong use case?

 

regards,

Marisa

 

Technical Evangelist
Posts: 599
Registered: ‎10-01-2015

Re: How to build a generalized raster with lower resolution than the input raster?

[ Edited ]

Hi Marisa,

 

The model should be doing exactly what you requested - it takes a 1m pixel size image, steps through the input image summing each window of 400 pixels that fall in a 20 x 20 array of pixels, and outputs a new raster with a pixel size of 20m and the DN value representing the sum.

 

What makes you think you aren't getting that result?

 

Cheers

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Frequent Contributor
Posts: 83
Registered: ‎07-17-2017

Re: How to build a generalized raster with lower resolution than the input raster?

Hi Ian,

 

After my first approach as explained in my last post the output looked like this:

raster_generalized1.JPG

 

I just changed my adapted model in the way that I generate the 1x1 raster from the vector layer in another model and take the stored output file as input of your model. Now my output raster looks like this (the black spots are the 1x1 m cells representing houses on my input raster after converting the point vector layer with the Vector input As Raster Operator.

 

raster_generalized.JPG

 

As you can see there are pixels with values not zero in areas where no houses can be find. The pattern of the raster values also seems to follow a certain pattern as I would expect it when interpolating raster data. And finally there is Nearest Neighbor defiend in the Raster input operator and the Warp operator. That's why I think it's not just calculating the plain sum.

I'm using ERDAS Imagine 2016.

 

Cheers

Marisa

 

 

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.