October 09, 2012

digging out the edge of the hill

Recently I had a possibility and time to look practically at the boundary questions, the ones I always like to philosophy about...  I got a simple task: to calculate the volume of a small heap (much smaller then hill) having an image with elevation values (DEM) and so I just needed to automatize and to simplify the steps that were already determined by others, mostly some routine work with ArcGIS (ESRI) tools, so just a bit of patience learning to geoprocess with python.

Digging the boundary  of a heap
But before starting the calculations I had to find out where is this heap and where it's not anymore. I had to draw clear boundaries in order to start some calculations at all. Apparently there was no tool for a heap determination founded where I work, till now all was done manually, by digitizing: zooming out and in, searching out that boundary where the heap starts or ends and going around.
The human brain is great, fast recognizing the pattern it searches for. Maybe recognizing just approximately, but nicely and unconsciously ignoring all other: small depressions, pikes or elevation model noise due to calculated heights of some bushes or some artificial constructions  or photogrametrical noise...
But the problem is that when having a huge images with a great resolution it takes hours and hours to load it and while zooming back and forward trying to draw a line in order to determine "exactly" where the heap starts or/and ends. Besides, when you start looking at a greater and greater resolution the picture of  all the image disappears and for our brain it becomes hard to process just various tones of colours in pixels in front. So, I needed to find how to automatize this first step in order I could work on the calculations. And just looking rather at a simple task or indeed at the DEM (it's prety nice!),  I fastly ran into a dark dark forest searching the way how to determine where this heap finishes or starts in order to be able to define it and build the script.

There is no simple definition how to bound natural objects. Of course there are theories about the boundaries, but it is always more about defining the types, names and outsearching the metathings. For example the differentiation in bona fide and fiat boundaries (http://www.columbia.edu/~av72/papers/Ppr_2000.pdf). So - fide - the topological boundary not determined clearly and when we difitize it, it becomes fiat. But well, this (my institutional) knowledge does not help much to solve the problem of turning one into other. To do so, one has to find really clear definitions, but Collins definition of FootHill ( 'Fuß' in german) - "a lower slope of a mountain or a relatively low hill at the foot of a mountain" again is not useful.

Having no clear definition, software alone is not so intelligent to recognize that heap and so to say to 'dig out' the boundary of it, since it is nothing about recognition. All lays within interpretation.. Well, there are indeed ways, like for example machine learning, but it is way too far from what I could possibly use to solve this problem.
What was left, try to find some definitions by myself.. and that took time: drawing profiles of those heaps and calculating usual parameters.. or producing slopes images and trying some roughness and ruggedness indexes with gdal library. But well, having generally very rugged surface, small heaps laying next to so some grabens - small cuts, trying to find some some mean values  was quite hard..
Some heaps were cleared, but some would dissapear in the average, the relief is not flat.

Filtering by average elevation values is not so successful
So, I learned to build larger filters (as usual ones in softwares were just 3x3 pixels..) in order to smooth it linearly and get less dynamic relief, at the same time unluckily easing up the slope foot a bit. But the slope function still did not produce any good result, as I wanted to get kind not the line exactly, but the polygon with crisp edge (what I needed for calculations). As producing lines it often happened the edge was left open, as from one side the heap was very steep and at the other very smoothly flowing into the flat land.

Finally I got the simple idea about standard deviation while filtering as it does not depend on absolute heights. After producing some images just of standard deviation of different size filters, I noticed some tendencies. Getting the variation of already smoothed values in for ex. 6x6 cells helped to find where the relief distortion starts growing. But to make a greater differences in the image I have decided to multiply the elevation values with the standard deviation. That gave me a result having very low values where the relief usual values weren't deviating much (having 0,2 or 0,5 deviation) and very high values where the where huge changes in the relief within that 6x6 cell filter, with a cell of 0,25 m. At the same time the lower values of the relief cuts although very rugged, but got lower and the higher heaps got higher values at the end.
The only one fast way to define the interval of values of that multipication to be taken as a mask was to check the averages and how much usual elevation values deviates from the averages.

Filtering using standard deviation multiplication with elevation
Indeed it wasn't the nicest solution, but after cleaning polygons from the small holes and small lifts up (like that noise around the heaps you see in the picture), I managed to "dig out" the foot of the heap. And while having a heap, to make calculations is just the clear way out of this forest..

No comments:

Post a Comment