Back to <a Tutorials index</a><hr><br>
<h1>Tutorial: adding a styled DEM to the Planet Earth sample</h1>
In this tutorial we'll use the following input Open Data datasource: please download it right now.
<ul>
<li><a a raw Global Relief Model released from NOAA.</li>
</ul>
If you remember, you've already used an ETOPO1 datasource in the previous <b><i>Planet tutorial; but it was a pre-rendered, full color version.<br>
Now you'll use exactly the same identical dataset, but this time you'll learn how to directly access a <i>raw</i> <a and how to apply your own custom styles to it.<br>
You'll possibly use yet again the same <b>earth.sqlite</b> DB-file used in the previous <b><i>Planet tutoral, and this will allow you to immediately perceive any relevant difference between these two different approaches.
<h3>Step 1) retrieve all basic informations about the ETOPO1 DEM</h3>
<verbatim>
$ tiffinfo ETOPO1_Ice_c_geotiff.tif
TIFF Directory at offset 0x8 (8)
  Image Width: 21600 Image Length: 10800
  Bits/Sample: 16
  Sample Format: signed integer
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Samples/Pixel: 1
  Rows/Strip: 1
  Planar Configuration: single image plane
  Tag 33550: 0.016667,0.016667,0.000000
  Tag 33922: 0.000000,0.000000,0.000000,-180.000000,90.000000,0.000000
  Tag 42112: <GDALMetadata>
  <Item
  <Item name="NC_GLOBAL#title">ETOPO1_Ice_c_gmt4.grd</Item>
  <Item name="NC_GLOBAL#history">grdsample -V ETOPO1_Ice_g_gmt4.grd -GETOPO1_Ice
_c_gmt4.grd=ni -T</Item>
  <Item name="NC_GLOBAL#GMT_version">4.4.0</Item>
  <Item name="NC_GLOBAL#node_offset">1</Item>
  <Item name="z#long_name">z</Item>
  <Item name="z#_FillValue">-2147483648</Item>
  <Item name="z#actual_range">-10803, 8333</Item>
  <Item name="x#long_name">Longitude</Item>
  <Item name="x#actual_range">-180, 180</Item>
  <Item name="x#units">degrees</Item>
  <Item name="y#long_name">Latitude</Item>
  <Item name="y#actual_range">-90, 90</Item>
  <Item name="y#units">degrees</Item>
  <Item name="NETCDF_VARNAME" sample="0">z</Item>
</GDALMetadata>

  Tag 42113: -2147483648
$
</verbatim>
As reported by the tool, this TIFF file contains a <b>21,600</b> x <b>10,800</b> raster; the suggested photometric interpretation is <b>Grayscale</b> and pixel values are of the <b>INT16</b> type (<b><i>Sample Format: signed and <b><i>Bits/Sample:
<u>Please note</u>: since now you've costantly encountered <b><i>unsigned samples; but ETOPO1 is a Global <b>DEM</b> covering both Continent surfaces and Ocean floors, and each pixel value corresponds to an <u><i>elevation So in this specific case using <b><i>signed is a perfectly reasonable solution, because we'll have elevations above sea level and elevations below sea level.
<verbatim>
$ listgeo ETOPO1_Ice_c_geotiff.tif
Geotiff_Information:
   Version: 1
   Key_Revision: 1.0
   Tagged_Information:
      ModelTiepointTag (2,3):
         0                 0                 0
         -180              90                0
      ModelPixelScaleTag (1,3):
         0.0166666666666667 0.0166666666666667 0
      End_Of_Tags.
   Keyed_Information:
      End_Of_Keys.
   End_Of_Geotiff.
$
</verbatim>
The tool confirms that this actually is GeoTIFF: unhappily it's a bogus GeoTIFF, missing to declare many relevant informations (e.g. the intended Reference System). So it's practically useless.
<verbatim>
0.0166666666666667
0.00000
0.00000
-0.0166666666666667
-180.00000
90.00000
</verbatim>
Anyway this isn't a blocking issue: you could easily add by yourself a WorldFile supporting the TIFF (as exemplified in the above snippet); or you could eventually just download it from <a
<h3>Step 2) creating the Etopo1_DEM Coverage</h3>
<verbatim>
$ rl2tool CREATE -db earth.sqlite -cov Etopo1_DEM -smp INT16 \
-pxl DATAGRID -cpr LZMA -srid 4326 -res 0.0166666666666667 -nd -9999

rl2_tool: request is CREATE
===========================================================
              DB path: earth.sqlite
             Coverage: Etopo1_DEM
          Sample Type: INT16
           Pixel Type: DATAGRID
      Number of Bands: 1
        NO-DATA pixel: -9999
          Compression: LZMA (7-zip, lossless)
   Tile size (pixels): 512 x 512
                 Srid: 4326
Pixel base resolution: X=0.0166666666666667 Y=0.0166666666666667
===========================================================

     SQLite version:
 SpatiaLite version: 4.2.0-devel
RasterLite2 version: 0.8

Raster Coverage "Etopo1_DEM" successfully created

Operation CREATE successfully completed
$
</verbatim>
<ul>
<li>Exactly as you already did in any previous you'll invoke from the command shell.</li>
<li>the most relevant arguments will be explained one by one:
<ul>
<li><b>-smp INT16</b> this specifies the Coverage's Sample Type.</li>
<li><b>-pxl DATAGRID</b> this specifies the Coverage's Pixel Type.<br>
<li><b>-cpr LZMA</b> this specifies that all Tiles in this Coverage must be  compressed using the <b>LZMA</b> algorithm.<br>
<u>Please note</u>: in this case using the common <b>JPEG</b> compression is completely out of discussion, because JPEG doesn't support 16 bit pixels.</li>

</ul>
<h3>Step 3) populating the Etopo1_DEM Coverage</h3>
<verbatim>
$ rl2tool IMPORT -db earth.sqlite -cov Etopo1_DEM -srid 4326 -wf \
-src ETOPO1_Ice_c_geotiff.tif -pyr

rl2_tool; request is IMPORT
===========================================================
              DB path: earth.sqlite
    Input Source path: ETOPO1_Ice_c_geotiff.tif
             Coverage: Etopo1_DEM
              Section: from file name
Using the WorldFile
          Forced SRID: 4326
Immediately building Pyramid Levels
===========================================================

     SQLite version:
 SpatiaLite version: 4.2.0-devel
RasterLite2 version: 0.8

Importing: ETOPO1_Ice_c_geotiff.tif
------------------
    Image Size (pixels): 21600 x 10800
                   SRID: 4326
       LowerLeft Corner: X=-180.00 Y=-90.00
      UpperRight Corner: X=180.00 Y=90.00
       Pixel resolution: X=0.0166666666666667 Y=0.0166666666666667
  ----------
    Pyramid levels successfully built for: ETOPO1_Ice_c_geotiff

Operation IMPORT successfully completed
$
</verbatim>
Exactly as you already did in any other previous tutorial.
<h3>Step 4) creating and loading your own custom Raster Styles</h3>
<h4>4.1) downloading the ETOPO1 styles</h4>
Just download the appropriate resource-pack from <a it contains any SLD/SE RasterSymbolizer required by this tutorial.
<h4>4.2) exploring the SLD/SE RasterSymbolizer anatomy</h4>
<verbatim>
<?xml version="1.0" encoding="UTF-8"?>
<RasterSymbolizer version="1.1.0"


	<Name>trieste_gamma_1.5</Name>
	<Description>
		<Title>Contrast Enhancement: GammaValue=1.5</Title>
		<Abstract>a styled 16-bit grayscale raster supporting contrast enhancement; GammaValue method (coeff=1.5)</Abstract>
	</Description>
	<Opacity>1.0</Opacity>
	<ContrastEnhancement>
		<GammaValue>1.5</GammaValue>
	</ContrastEnhancement>
</RasterSymbolizer>
</verbatim>
Any RasterSymbolizer simply is an <b><i>XML i.e. a <b><i>text you can safely use any ordinary text editor in order to view and eventually modify a RasterSymbolizer:


<h4>4.3) importing all RasterSymbolizers into the DB-file</h4>
<verbatim>
$ sqlite3 earth.sqlite
SQLite version 2014-03-26 18:51:19
Enter ".help" for usage hints.
sqlite> .null NULL
sqlite> SELECT load_extension('mod_spatialite');
NULL
sqlite> SELECT CreateStylingTables();
1
sqlite> SELECT RegisterRasterStyledLayer('etopo1_dem',
   ...> 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('etopo1_dem',
   ...> 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('etopo1_dem',
   ...> 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('etopo1_dem',
   ...> 1, 1));
1
sqlite> .quit
$
</verbatim>
This step exactly corresponds to the task already explained in the and tutorials.
<h3>Step 5) testing the ETOPO1_DEM sample (and playing with Styles)</h3>
As you've already done in any previous you can now directly test the ETOPO1_DEM Coverage by publishing a standard WMS service.<br>
You simply have to start the light-weight server, then connecting some WMS viewer (e.g. to the service being published on aka IP address port
<img alt="ETOPO1 default"><br>
This first example corresponds to the <u>default</u> Style (no RasterSymbolizer at all): in this case just a basic Grayscale rendering is applyed. Not a really interesting option.<br><br>
<img alt="ETOPO1 categorize"><br>
This second example corresponds to the <b>etopo_categorize</b> style.<br>
You can fully appreciate what a <b>ColorMap</b> of the <b>Categorize</b> type implies; all elevations falling the same class interval have now received the same identical color; and the final result is an unpleasant ugly map.<br><br>
<img alt="ETOPO1 etopo style"><br>
This third example corresponds to the <b>etopo</b> style; now the <b>ColorMap</b> is of the <b>Interpolate</b> type, and the final result is much more brilliant then before.<br>
<u>Please note well</u>: both the <b>etopo_categorize</b> and the <b>etopo</b> style share exactly the same identical <b>ColorMap</b>; but the <b>etopo</b> style supports the <b>Interpolate</b> rendering, thus producing a wide range of different color shades, and the overall effect surely is a pleasant one.<br><br>
<img alt="ETOPO1 terrain"><br>
This fourth example corresponds to the <b>terrain</b> style; it's very similar to <b>etopo</b>, but in this case deep waters are simply represented as black areas, so to focus the attention on Lands and nearby shallow waters.<br><br>
<img alt="ETOPO1 srtm_plus"><br>
This final example corresponds to the <b>srtm_plus</b> style. As you can easily notice, it's not at all difficult creating completely different maps starting from the same identical DEM Coverage; you are simply required to define few alternative Styles and that's all.
<br><br>
<hr><br>
Back to <a Tutorials index</a>