10

The concept of composite hillshade is to combine multiple hillshades with different sunlight orientation to avoid blind spot. It requires to merge 3 hillshades images with 315⁰ (NW sunlight, default layer), +355⁰ layer, +275⁰ sunlights, respectively. This increase details and elegance, as shown below.A full non-GIS description is here.

enter image description here

Using any srtm file, the 3 initial hillshades can be done via :

gdaldem hillshade input.tif hillshades_A.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges
gdaldem hillshade input.tif hillshades_B.tmp.tif -s 111120 -z 5 -az 355 -alt 60 -compute_edges
gdaldem hillshade input.tif hillshades_C.tmp.tif -s 111120 -z 5 -az 275 -alt 60 -compute_edges
9

The linked source mention "change its fusion mode to < Multiply >", so the operation to do is not a simple average of input hillshades (for this, see also How to average gdal_hillshades?). It's something else. Yet, let's create the 3 different-sunlight-directions hillshades :

gdaldem hillshade input.tif hillshades_A.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges
gdaldem hillshade input.tif hillshades_B.tmp.tif -s 111120 -z 5 -az 355 -alt 60 -compute_edges
gdaldem hillshade input.tif hillshades_C.tmp.tif -s 111120 -z 5 -az 275 -alt 60 -compute_edges

enter image description here

Keep lowest value of A,B,C

The first algorithm I though about is to filter and keep the darkest pixels, aka the pixels with lower values among input A,B,C.A boolean can do that :

gdal_calc.py -A hillshades_A.tmp.tif  -B hillshades_B.tmp.tif -C hillshades_C.tmp.tif --outfile=./hillshades_xl.tmp.tif \
   --calc="(A*(A<=B)*(A<=C)+ B*(B<A)*(B<=C)+ C*(C<A)*(C<B))"

The area dominated by shadows now make up more than the opposite side of one central lignt, it been increase by 40⁰ on each side. Not as the link provided, this current algorithm seems to lost too much the enlighten area.

Angle of 315±30⁰ (smaller angle variation) rather that current 315±40⁰ would do nicer.

The diagram below is a the basis of the equation. It shows light sources A, B, C, and the Boolean comparisons for pixels values A, B, C in each part. Equality lines need a special attention to be included into the Boolean. The median lines have value 221 for the perpendicular light source. Think about areas of influence, the closest source of light is the main influence, and the farest the weakest influence.

enter image description here

Keep extremes values for A,B,C

An other Boolean algorithm could be to keep the most extreme values, both the darkest and the whitest pixels. The following diagram helps to thing about the Boolean formula. For each sixth of the circle, it identifies the value to keep from A,B,C, and a Boolean to select the triangular area plus the clockwise equality line, and only that. It gives (from top and clockwise) :

--calc="A*(A>B)*(A>=C) + C*(C>A)*(A>=221) + B*(C>A)*(C>=221) + A*(A<B)*(B<=221) + C*(B>A)*(A<=221) + B*(B>A)*(C<=221)"

enter image description here

If the angles variations is not too important, it could give good results.

Other Booleans

You may create more complex Boolean to cover the whole circles using any combination the border segments. It stays important that only one value out of A,B,C is kept for one segment.

Multiply

I made several failled attempts to multiply pixels values without a proven formula nor final success. @Radouxju pointed out that (a*b*c)^(1/3) (GEOMETRIC mean) instead of the ARITHMETIC mean (a*b*c)/(255*255) may work. Geometric mean is lower or equal to arithmetic mean, which accentuates the darkness of shaded areas. I haven't tested it yet.

  • I tried to sum up my conceptual learning on composite and how someone could custom it. The real formula for "multiply" stays unknown to me. – Hugolpz May 8 '15 at 14:52
  • Why not just multiply the values and rescale the results? – whuber May 8 '15 at 16:07
  • Haven't tried! Which formula would do it, (A*B*C)/(255*255) ? – Hugolpz May 8 '15 at 16:11
  • 1
    That would be a good start :-). – whuber May 8 '15 at 16:12
  • 1
    isn't "multiply" using the GEOMETRIC mean instead of the ARITHMETIC mean. (abc)^(1/3). Geometric mean is lower or equal to arithmetic mean, which accentuates the darkness of shaded areas. – radouxju May 13 '15 at 6:44
0

A tool that can do this (among others) is the Sky-View Factor Based Visualization (http://iaps.zrc-sazu.si/en/svf#v). Calculate several parameters of a terrain. Is damn good.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

-1

Gdal_calc's numpy seems to have more operators :

+ addition 
- subtraction 
/ division 
* multiplication 
= equals to 
< less than 
> larger than 
! not equal to 
? if clause 
M maximum of two values 
m minimum of two values 
B bit level operator

I haven't found clear and proper examples for how the exotic operators should be used. If you have something, feel free to share.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.