9
a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced Level (1) section. This tutorial simply still continues examining the rl_grid_paint tool, this time focusing attention about the astonishing Shaded Relief feature. Yes, it's only a very specific key single feature, but this specific topic is complex enough to require a separate tutorial by its own. Session #3: producing Shaded Relief imagery The so called Shaded Relief aka Hill-Shade is a powerful technique invented many centuries ago (well before computing invention). Ancient cartographers discovered that applying an appropriate shadowing to a map will produce a noticeable 3D effect, thus making the map much more easy to read (and much more attractive, of course). Applying Shaded Relief to some given map can be described by the following steps: imagine a single punctiform light source (i.e. the Sun) set an appropriate position for such light source: this position is defined in a 3D space, so you must define and azimuth and and altitude. There is no need to specify a distance, because the light source is supposed to be placed at infinite distance, so to produce parallel rays. now you can carefully compute how strong is the shadowing effect for each single point of the map, simply verifying the actual slope and orientation of the underlying terrain. In ancient times producing a Shaded Relief map by hand was a very long and extenuating process: but nowadays, in the computer era, producing wonderful Shaded Relief maps is just a matter of seconds. Applying the Shaded Relief algorithm to a grid image belonging to the DEM (Digital Elevation Model) family simply is a piece of cake. The rl_grid_paint tool supports the Shaded Relief algorithm, so we'll now go to see how you can take full profit of this very interesting feature. During this tutorial session we'll simply retake the same examples we already used in the previous session, this time applying Shaded Relief. Aknoledgments: the current RL tools Shaded Relief implementation is widely based on the original one developed for GRASS and GDAL by Even Rouault of Ecole des Mines in Paris. Even's implementation is really simple and very efficient: we all are in debt with Even for his wonderful work. Thanks a lot, Even !!

a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Embed Size (px)

Citation preview

Page 1: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

a quick introduction to RL toolsadvanced level (2)

You are supposed to have just read the corresponding Advanced Level (1) section.

This tutorial simply still continues examining the rl_grid_paint tool, this time focusing attention about the astonishing Shaded Relief feature.

Yes, it's only a very specific key single feature, but this specific topic is complex enough to require a separate tutorial by its own.

Session #3: producing Shaded Relief imageryThe so called Shaded Relief aka Hill-Shade is a powerful technique invented many centuries ago (well before computing invention). Ancient cartographers discovered that applying an appropriate shadowing to a map will produce a noticeable 3D effect, thus making the map much more easy to read (and much more attractive, of course).

Applying Shaded Relief to some given map can be described by the following steps:

• imagine a single punctiform light source (i.e. the Sun)• set an appropriate position for such light source: this position

is defined in a 3D space, so you must define and azimuth and and altitude. There is no need to specify a distance, because the light source is supposed to be placed at infinite distance, so to produce parallel rays.

• now you can carefully compute how strong is the shadowing effect for each single point of the map, simply verifying the actual slope and orientation of the underlying terrain.

In ancient times producing a Shaded Relief map by hand was a very long and extenuating process: but nowadays, in the computer era, producing wonderful Shaded Relief maps is just a matter of seconds. Applying the Shaded Relief algorithm to a grid image belonging to the DEM (Digital Elevation Model) family simply is a piece of cake.

The rl_grid_paint tool supports the Shaded Relief algorithm, so we'll now go to see how you can take full profit of this very interesting feature.

During this tutorial session we'll simply retake the same examples we already used in the previous session, this time applying Shaded Relief.

Aknoledgments: the current RL tools Shaded Relief implementation is widely based on the original one developed for GRASS and GDAL by Even Rouault of Ecole des Mines in Paris.Even's implementation is really simple and very efficient: we all are in debt with Even for his wonderful work. Thanks a lot, Even !!

Page 2: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Exercise #1:

>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.tif -nd -99999 -sr >rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.tif -nd -99999 -sr -sf 16>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -m 0xffffd8>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -sf 16 -m 0xe0fff0

Asking rl_grid_paint to apply the Shaded Relief algorithm really is an easy task:• the -sr argument will turn-on the Shaded Relief feature. -sr stands for shaded-relief.• you can tune the light intensity at your will using the -sf value or the -z value arguments. -sf

stands for scale-factor, -z stands for z-factor. They are very similar, except that:◦ -sf works as a multiplier: as higher its value, as higher the light intensity will be.◦ -z works the opposite way, i.e. as a divisor: as lower its value, as higher the light

intensity.• the Shaded Relief algorithm by itself will always produce a Grayscale output image,

representing actual shadowing intensity: but you can apply a dominant color (if you wish to do so) simply using the -m hex-rgb-color argument. -m stands for monochrome-dominant.

Some visual example surely helps to understand better:

Simply applying Shaded Relief with default arguments will produce a very dark highly contrasted image.

Page 3: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Applying -sf 16 will produce a brighter, normally contrasted image.

And applying -z 0.02 you can get a similar effect (brighter image).

There is no optimal universal setting. As always when aesthetic considerations play a big role, it's more matter of personal taste than objective evaluation.As a rule-of-the-thumb, you must patiently find the best appropriate settings for your map by trial-and-error.

Page 4: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Applying a dominant color may help to improve visual appearance: here is -m 0xffffd8, i.e. yellowish.

But nothing forbids you to use a greenish dominant, if you think this will be more appropriate: in this case, it's -m 0xe0fff0

Yet again: it's matter of personal taste.Find your way by yourself, simply making some little experimation in order to acquire sufficient experience, and then use your good sense.

This first execise is terminated.Now you basically know what Shaded Relief is.

Page 5: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Exercise #2:

>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -sf 16 -z 0.02 -cr etopo2>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -sf 16 -cr etopo2

The rl_grid_paint tool is also capable to merge a color rules rendered image and Shaded Relief (and this technique produces highly spectacular, eye-catching maps).

This first sample was generated using -z 0.02

This second sample was generated using -sf 16: in both case the etopo2 color rules where applied.It's quite evident that different light intensities will produce a more or less strongly evidenced relief.

This second exercise is completed.I presume that at this point you are beginning to be fond of the wonderful Shaded Relief.

Page 6: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Exercise #4:

This time you'll switch to SRTM samples in order to perform this exercise: using an high resolution map (instead of the worldwide ETOPO1) will help to understand better.

>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.02 -cr srtm>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.08 -cr srtm>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.2 -cr srtm

-z 0.02 -z 0.05

-z 0.08 -z 0.2

The above samples speak eloquently: changing the light intensity factor has a dramatic effect.There is no objective criteria to establish which one of them is the best one: anyway, you have just discovered that you can perform fine tuning accordingly to your specific needs.

>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm -alt 75>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm -alt 25

Page 7: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

You can control the relief appearance following a differ way:• i.e. using the -alt degrees argument. -alt stands for altitude.• in other words, you can control the altitude of the light source (Sun) over the horizon.

-alt 75 -alt 25

Just some elementary consideration:• The default value corresponds to -alt 45: i.e. the Sun is placed exactly half way between the

horizon and the zenith.• When setting -alt 75 the Sun will be very near to the zenith (i.e. at noon), so light will be

brighter, and shadows will be very short. As a result the relief will appear to be flattened.• When setting -alt 25 the Sun will be very close to the horizon (i.e. at dusk), so light will be

darker, and shadows will be very long. As a result the relief will appear to be enhanced.

>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm -az 180>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm -az 225>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm -az 270>rl_grid_paint -i N42E012.hgt -o etopo.jpg -sr -z 0.05 -cr srtm

There is another interesting parameter you can set for fine tuning purposes:• using the -az angle argument you can control the direction from which the light comes. -az

stands for azimuth.

Please note: default settings are: -az 315 -alt 45.

Such values are not at all choosen at random: they adhere to a really old convention.Any map historically produced in the past (and nowadays) will place conventionlly place the Sun at this point: so think twice before adopting different settings.

Page 8: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

-az 180 -az 225

-az 270 -az 315 [default]

This closely simulates the light condition changes during the day, as Sun goes from East (at dawn) towards West (at dusk).

This fourth exercise is completed.Now you are assumed to be completely able to master the Shaded Relief algorithm, and to known how to customize the many options it supports.

Page 9: a quick introduction to RL tools advanced level (2) - gaia-gis.it · a quick introduction to RL tools advanced level (2) You are supposed to have just read the corresponding Advanced

Exercise #5:

Processing grids is a computationally heavy work: and (usually) grids has many millions pixels to be processed … so rendering a grids tends to be a slow and sluggish process.And applying Shaded Relief to a grid is by far an heavier task, because more computations are required in order to determine the exact light conditions for each pixel.

It's very probable that you have noticed in the previous exercises that rl_grid_paint tends to be quite slow when compared with other RL tools.

>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -nt 1>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -nt 2>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -nt 3>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -nt 4>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -nt 8>rl_grid_paint -i ETOPO1_Ice_g.tif -o etopo.jpg -nd -99999 -sr -z 0.02 -nt 16

Happily, we can process grid related algorithms in a parallel way: i.e. we can take full profit from multithrading: and modern CPUs does actually have many cores. e.g. I'm currently using an Intel i5 processor supporting 2 physical cores and 4 logical cores: so I'm able to run 4 concurrent threads.

• you can use the -nt num-threads argument in order to activate concurrent multithreading. -nt stands for num-threads.

• the default setting used by rl_grid_paint is -nt 2: so at least a minimal degree of concurrency is assured anyway.

• but you can increase this value in order to get a better performance: on my Intel i5 -nt 8 seems to be the best option. (yes, there aren't so many logical cores: but probably a number of threads greater than the number of logical cores optimizes the operating system's scheduler).

• using more concurrent threads seems not to negatively affect single core CPUs: anyway you can explicitly set -nt 1, and this will grant you a traditional mono-threaded execution.

Please note: doubling the number of concurrent threads (if you have enough supporting CPU cores) does not cut timings exectly by a 2 factor.

This is because pixels processing will be performed in a parallel fashion, but I/O related tasks will be processed by a single thread anyway.

But increasing the number of concurrent threads is the best way to take full profit from multi-core architecture adopted by any recent CPU.

All right, this third advanced tutorial is completed.

If you have undestood any topic we have examined since yet, then you are now ready to start processing astonishing raster maps by yourself.

Good luck ... and enjoy yourself !