03-18-2018 03:24 AM
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!
Solved! Go to Solution.
03-19-2018 02:08 AM
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??
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.
03-19-2018 08:18 AM - edited 03-19-2018 08:20 AM
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.
03-19-2018 09:54 AM
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.
03-19-2018 10:19 AM
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...!
03-19-2018 10:25 AM
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.
03-20-2018 01:10 AM - edited 03-20-2018 06:14 AM
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.
Timo - the one who is learning Iterator operator just now
03-20-2018 08:43 AM
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?
03-20-2018 08:52 AM - edited 03-20-2018 08:53 AM
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?
03-20-2018 09:31 AM
After my first approach as explained in my last post the output looked like this:
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.
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.