trento-DEM
Not logged in

Back to RasterLite2 Tutorials index



Tutorial: adding a Shaded Relief DEM to the Trento sample

If you remember, you've already created a DB-file in the previous Trento tutorial. You'll possibly use yet again the same trento.sqlite DB-file, so to allow an easy and immediate comparison of both datasources.

In this tutorial you'll go to create a sophisticated LIDAR DEM presenting a very high resolution: 1 pixel = 1 meter. And you'll then learn how to apply a Shaded Relief 3D effect to your maps.

Step 1) dowloading all required LIDAR DEM files

This is the complete list of all files you are expected to download:
  1. dtm000849_wor.asc
  2. dtm000850_wor.asc
  3. dtm000901_wor.asc
  4. dtm000902_wor.asc
  5. dtm000903_wor.asc
  6. dtm000904_wor.asc
  7. dtm000954_wor.asc
  8. dtm000955_wor.asc
  9. dtm000956_wor.asc
  10. dtm000957_wor.asc
  11. dtm001004_wor.asc
  12. dtm001005_wor.asc
  13. dtm001006_wor.asc
  14. dtm001007_wor.asc
  15. dtm001008_wor.asc
  16. dtm001050_wor.asc
  17. dtm001051_wor.asc
  18. dtm001052_wor.asc
  19. dtm001053_wor.asc
  20. dtm001054_wor.asc
  21. dtm001055_wor.asc
  22. dtm001056_wor.asc
  23. dtm001098_wor.asc
  24. dtm001099_wor.asc
  25. dtm001100_wor.asc
  26. dtm001101_wor.asc
  27. dtm001102_wor.asc
  28. dtm001103_wor.asc
  29. dtm001104_wor.asc
  30. dtm001146_wor.asc
  31. dtm001147_wor.asc
  32. dtm001148_wor.asc
  33. dtm001149_wor.asc
  34. dtm001150_wor.asc
  35. dtm001151_wor.asc
  36. dtm001152_wor.asc
  37. dtm001193_wor.asc
  38. dtm001194_wor.asc
  39. dtm001195_wor.asc
  40. dtm001196_wor.asc
  41. dtm001197_wor.asc
  42. dtm001198_wor.asc
  43. dtm001199_wor.asc
  44. dtm001241_wor.asc
  45. dtm001242_wor.asc
  46. dtm001244_wor.asc
  47. dtm001245_wor.asc
  48. dtm001246_wor.asc
  49. dtm001288_wor.asc
  50. dtm001289_wor.asc
  51. dtm001291_wor.asc
  52. dtm001292_wor.asc
  53. dtm001293_wor.asc

Step 2) creating the Trento_DEM Coverage

$ rl2tool CREATE -db trento.sqlite -cov lidar-dem -smp FLOAT \
-pxl DATAGRID -cpr DEFLATE -srid 32632 -res 1.0 -nd -9999

rl2_tool: request is CREATE
===========================================================
              DB path: trento.sqlite
             Coverage: lidar-dem
          Sample Type: FLOAT
           Pixel Type: DATAGRID
      Number of Bands: 1
        NO-DATA pixel: -9998.999999999999
          Compression: DEFLATE (zip, lossless)
   Tile size (pixels): 512 x 512
                 Srid: 25832
Pixel base resolution: X=1.0 Y=1.0
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0
RasterLite2 version: 1.0.0-rc0

Raster Coverage "lidar-dem" successfully created

Operation CREATE successfully completed
$

Step 3) populating the Trento_DEM Coverage

$ rl2tool IMPORT -db trento.sqlite -cov lidar-dem -srid 25832 \
  -dir . -ext .asc

rl2_tool; request is IMPORT
===========================================================
              DB path: trento.sqlite
 Input Directory path: .
       File Extension: asc
             Coverage: lidar-dem
              Section: from file name
          Forced SRID: 25832
Ignoring Pyramid Levels for now
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0
RasterLite2 version: 1.0.0-rc0

Importing: ./dtm000849_wor.asc
------------------
    Image Size (pixels): 2020 x 2020
                   SRID: 25832
       LowerLeft Corner: X=663990.00 Y=5111990.00
      UpperRight Corner: X=666010.00 Y=5114010.00
       Pixel resolution: X=1.0 Y=1.0

<=================> s n i p <=================>

Importing: ./dtm001293_wor.asc
------------------
    Image Size (pixels): 2020 x 2020
                   SRID: 25832
       LowerLeft Corner: X=665990.00 Y=5093990.00
      UpperRight Corner: X=668010.00 Y=5096010.00
       Pixel resolution: X=1.0 Y=1.0

Operation IMPORT successfully completed

$

Step 4) Creating a Monolithic Pyramid

You probably noticed that during the previous step no immediate Pyramid generation was required.
This was because we are going to create now a Monolithic Pyramid.
$ rl2tool PYRAMIDIZE-MONOLITHIC -db trento.sqlite -cov lidar-dem

rl2_tool; request is PYRAMIDIZE-MONOLITHIC
===========================================================
DB path: trento.sqlite
Coverage: lidar-dem
Pyramid Virtual Levels: default
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0
RasterLite2 version: 1.0.0-rc0

  ----------
    lidar-dem: Monolithic Pyramid Level 1 - Row 1 of 5  successfully built
  ----------
    lidar-dem: Monolithic Pyramid Level 1 - Row 2 of 5  successfully built
  ----------
    lidar-dem: Monolithic Pyramid Level 1 - Row 3 of 5  successfully built
  ----------
    lidar-dem: Monolithic Pyramid Level 1 - Row 4 of 5  successfully built
  ----------
    lidar-dem: Monolithic Pyramid Level 1 - Row 5 of 5  successfully built
  ----------
    lidar-dem: Monolithic Pyramid Level 2 - Row 1 of 1  successfully built
  ----------
    lidar-dem: Monolithic Pyramid Level 3 - Row 1 of 1  successfully built
  ----------
    Monolithic Pyramid levels successfully built for: lidar-dem

Operation PYRAMIDIZE-MONOLITHIC successfully completed
$
SELECT RL2_SetCoverageInfos('lidar-dem', 'Digital Elevation Model', '1m/pixel DEM from LIDAR relief')
Please remember: always setting a TITLE and an ABSTRACT for any Coverage being creates always is a strongly recommended good practice.

Step 5) creating and loading your own custom Raster Styles

5.1) downloading the Trento-DEM styles

Just download the appropriate resource-pack from here; it contains any SLD/SE RasterSymbolizer required by this tutorial.

5.2) exploring the SLD/SE RasterSymbolizer anatomy

<RasterSymbolizer version="1.1.0" 
                xsi:schemaLocation="http://www.opengis.net/se http://schemas.opengis.net/se/1.1.0/Symbolizer.xsd"  
                xmlns="http://www.opengis.net/se"
                xmlns:ogc="http://www.opengis.net/ogc"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Name>srtm_plus_ShRel</Name>
	<Description>
		<Title>SRTM-Plus Color Map + Shaded Relief</Title>
		<Abstract>derived from the original "srtm_plus" color rule (GRASS GIS)</Abstract>
	</Description>
	<Opacity>1.0</Opacity>
	<ColorMap>
		<Interpolate fallbackValue="#ffffff">
			<LookupValue>Rasterdata</LookupValue>
			<InterpolationPoint>
				<Data>-11000.00000000</Data>
				<Value>#000000</Value>
			</InterpolationPoint>
			<InterpolationPoint>
				<Data>-8000.00000000</Data>
				<Value>#000032</Value>
			</InterpolationPoint>
...
			<InterpolationPoint>
				<Data>8850.00000000</Data>
				<Value>#6464c8</Value>
			</InterpolationPoint>
		</Interpolate>
	</ColorMap>
	<ShadedRelief />
</RasterSymbolizer>
You surely remember the <ColorMap> SLD/SE declaration; we've already encountered this feature in the previous ETOPO-1 tutorial, and we've already explained there how the srtm_plus style works.
Pay close attention: in this case there is a further SLD/SE declaration, i.e. <ShadedRelief>; this implies simulating a light source in a conventional position then computing all shadows created by the terrain relief. This one is a computationally heavy calculation, but allows to create very nice maps with a striking 3D appearance.

...
	<ShadedRelief>
		<ReliefFactor>40.0</ReliefFactor>
	</ShadedRelief>
...
That's not all: you could eventually specify some appropriate <ReliefFactor> so to make the shadow effect more or less evident, accordingly to your intentions.

<?xml version="1.0" encoding="UTF-8"?>
<RasterSymbolizer version="1.1.0" 
                xsi:schemaLocation="http://www.opengis.net/se http://schemas.opengis.net/se/1.1.0/Symbolizer.xsd" 
                xmlns="http://www.opengis.net/se" 
                xmlns:ogc="http://www.opengis.net/ogc"   
                xmlns:xlink="http://www.w3.org/1999/xlink" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Name>shaded_relief_factor_40</Name>
	<Description>
		<Title>Shaded Relief BrightnessOnly Factor 40</Title>
		<Abstract>an uncolored Shaded Relief (brightness only) - relief factor 40</Abstract>
	</Description>
	<Opacity>1.0</Opacity>
	<ShadedRelief>
		<ReliefFactor>40.0</ReliefFactor>
	</ShadedRelief>
</RasterSymbolizer>
Finally there is a third variant supported by the SLD/SE RasterSymbolizer: you could eventually omit at all any <ColorMap> declaration anyway still continuing to request <ShadedRelief>. And in this case a pure brightness map (gray) will be generated accordingly to the relative light intensities.

5.3) importing all RasterSymbolizers into the DB-file

$ sqlite3 trento.sqlite
SQLite version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for usage hints.
sqlite> .null NULL
sqlite> SELECT load_extension('mod_spatialite');
NULL
sqlite> SELECT CreateStylingTables();
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/srtm_plus.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/srtm_plus_ShRel.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/srtm_plus_ShRel_25.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/srtm_plus_ShRel_40.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/srtm_plus_ShRel_75.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/srtm_plus_ShRel_100.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/shaded_relief_default.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/shaded_relief_factor_25.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/shaded_relief_factor_40.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar_dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/shaded_relief_factor_75.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('lidar-dem',
   ...> XB_Create(XB_LoadXML('./trento_styles/shaded_relief_factor_100.xml'), 1, 1));
1
sqlite> .quit
This step exactly corresponds to the task already explained in several of the previous tutorials.

Step 6) testing the Trento-DEM sample (and playing with Styles)

As you've already done in any previous tutorial you can now directly test the Trento-DEM Coverage by publishing a standard WMS service.
You simply have to start the wmslite light-weight server, then connecting some WMS viewer (e.g. LibreWMS) to the service being published on localhost aka IP address 127.0.0.1, port 8080.

Trento DEM default
default style; this actually corresponds to just rescaling DEM elevations so to match a grayscale. Not really interesting.

Trento DEM color map
srtm_plus style: in this case an appropriate <ColorMap> was applied so to transform DEM elevations into false-colors.

Trento DEM shaded relief
srtm_plus_ShRel style; exactly as in the previous figure the same <ColorMap> was applied. But in this case a <ShadedRelief> effect was then added by using the default setting.

Trento DEM shaded relief 25
srtm_plus_ShRel_25 style: same as above, but explicitly requesting <ReliefFactor>25</ReliefFactor> (very bland effect).

Trento DEM shaded relief 40
srtm_plus_ShRel_40 style: same as above, but explicitly requesting <ReliefFactor>40</ReliefFactor> (medium effect).

Trento DEM shaded relief 75
srtm_plus_ShRel_75 style: same as above, but explicitly requesting <ReliefFactor>75</ReliefFactor> (strong effect).

Trento DEM shaded relief 100
srtm_plus_ShRel_100 style: same as above, but explicitly requesting <ReliefFactor>100</ReliefFactor> (very strong effect).

Trento DEM brightness default
shaded_relief_default style; this time <ShadedRelief> alone (default setting) was declared, without specifying any <ColorMap>. This corresponds to pure brightness.

Trento DEM brightness 25
shaded_relief_25 style: same as above, but explicitly requesting <ReliefFactor>25</ReliefFactor> (very bland effect).

Trento DEM brightness 40
shaded_relief_40 style: same as above, but explicitly requesting <ReliefFactor>40</ReliefFactor> (medium effect).

Trento DEM brightness 75
shaded_relief_25 style: same as above, but explicitly requesting <ReliefFactor>75</ReliefFactor> (strong effect).

Trento DEM brightness 100
shaded_relief_100 style: same as above, but explicitly requesting <ReliefFactor>100</ReliefFactor> (very strong effect).



Back to RasterLite2 Tutorials index