trento-ctr
Not logged in

Back to RasterLite2 Tutorials index



Tutorial: adding a 1-bit Monochrome Coverage to the Trento sample

Please reuse yet again the same trento.sqlite DB-file created in the previous Trento tutorial, so to allow an easy and immediate comparison of both datasources.

In this tutorial you'll go to add a further Coverage on the same geographic extent, this time using a 1-bit monochrome datasource.

Step 1) dowloading all required CTR files

This is the complete list of all files you are expected to download:
  1. CTP2013_060020
  2. CTP2013_060050
  3. CTP2013_060060
  4. CTP2013_060090
  5. CTP2013_060100
  6. CTP2013_060110
  7. CTP2013_060130
  8. CTP2013_060140
  9. CTP2013_081010
  10. CTP2013_081020

Step 2) creating the Trento CTR Coverage

$ rl2tool CREATE -db trento.sqlite -cov ctr -smp 1-BIT \
-pxl MONOCHROME -cpr FAX4 -srid 25832 -res 0.6773

rl2_tool: request is CREATE
===========================================================
              DB path: trento.sqlite
             Coverage: ctr
          Sample Type: 1-BIT
           Pixel Type: MONOCHROME
      Number of Bands: 1
          Compression: CCITT FAX4, lossless
   Tile size (pixels): 512 x 512
                 Srid: 25832
Pixel base resolution: X=0.6773 Y=0.6773
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0-rc1
RasterLite2 version: 0.8

Raster Coverage "ctr" successfully created
$

Step 3) populating the Trento CTR Coverage

$ rl2tool IMPORT -db trento.sqlite -cov ctr -srid 25832 \
-wf -dir . -ext .tif

rl2_tool; request is IMPORT
===========================================================
              DB path: trento.sqlite
 Input Directory path: .
       File Extension: .tif
             Coverage: ctr
              Section: from file name
Using the WorldFile
          Forced SRID: 25832
Ignoring Pyramid Levels for now
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0-rc1
RasterLite2 version: 0.8

Importing: ./CTP2013_060020.tif
------------------
    Image Size (pixels): 9718 x 8458
                   SRID: 25832
       LowerLeft Corner: X=660659.05 Y=5112721.39
      UpperRight Corner: X=667241.08 Y=5118449.97
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060050.tif
------------------
    Image Size (pixels): 9718 x 8448
                   SRID: 25832
       LowerLeft Corner: X=654370.11 Y=5107000.43
      UpperRight Corner: X=660952.14 Y=5112722.24
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060060.tif
------------------
    Image Size (pixels): 9726 x 8456
                   SRID: 25832
       LowerLeft Corner: X=660805.29 Y=5107166.67
      UpperRight Corner: X=667392.74 Y=5112893.90
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060090.tif
------------------
    Image Size (pixels): 9726 x 8450
                   SRID: 25832
       LowerLeft Corner: X=654509.36 Y=5101444.36
      UpperRight Corner: X=661096.81 Y=5107167.52
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060100.tif
------------------
    Image Size (pixels): 9734 x 8458
                   SRID: 25832
       LowerLeft Corner: X=660951.03 Y=5101610.59
      UpperRight Corner: X=667543.90 Y=5107339.17
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060110.tif
------------------
    Image Size (pixels): 9742 x 8468
                   SRID: 25832
       LowerLeft Corner: X=667392.21 Y=5101782.65
      UpperRight Corner: X=673990.49 Y=5107518.00
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060130.tif
------------------
    Image Size (pixels): 9734 x 8448
                   SRID: 25832
       LowerLeft Corner: X=654649.60 Y=5095889.63
      UpperRight Corner: X=661242.47 Y=5101611.44
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_060140.tif
------------------
    Image Size (pixels): 9744 x 8458
                   SRID: 25832
       LowerLeft Corner: X=661096.10 Y=5096054.69
      UpperRight Corner: X=667695.74 Y=5101783.27
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_081010.tif
------------------
    Image Size (pixels): 9742 x 8448
                   SRID: 25832
       LowerLeft Corner: X=654789.34 Y=5090333.73
      UpperRight Corner: X=661387.63 Y=5096055.54
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999
Importing: ./CTP2013_081020.tif
------------------
    Image Size (pixels): 9752 x 8458
                   SRID: 25832
       LowerLeft Corner: X=661241.84 Y=5090499.79
      UpperRight Corner: X=667846.90 Y=5096228.37
       Pixel resolution: X=0.6773030012999999 Y=0.6772972164999999

Operation IMPORT successfully completed
$

Step 4) Creating a Monolithic Pyramid

$ rl2tool PYRAMIDIZE-MONOLITHIC -db trento.sqlite -cov ctr -lev 1


rl2_tool; request is PYRAMIDIZE-MONOLITHIC
===========================================================
DB path: trento.sqlite
Coverage: ctr
Pyramid Virtual Levels: 1
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0-rc1
RasterLite2 version: 0.8

  ----------
    ctr: Monolithic Pyramid Level 1 - Row 1 of 41  successfully built
  ----------
    ctr: Monolithic Pyramid Level 1 - Row 2 of 41  successfully built
  ----------
...................................
  ----------
    ctr: Monolithic Pyramid Level 1 - Row 40 of 41  successfully built
  ----------
    ctr: Monolithic Pyramid Level 1 - Row 41 of 41  successfully built
  ----------
    ctr: Monolithic Pyramid Level 2 - Row 1 of 21  successfully built
  ----------
    ctr: Monolithic Pyramid Level 2 - Row 2 of 21  successfully built
  ----------
...................................
  ----------
    ctr: Monolithic Pyramid Level 2 - Row 20 of 21  successfully built
  ----------
    ctr: Monolithic Pyramid Level 2 - Row 21 of 21  successfully built
  ----------
    ctr: Monolithic Pyramid Level 3 - Row 1 of 11  successfully built
  ----------
    ctr: Monolithic Pyramid Level 3 - Row 2 of 11  successfully built
  ----------
    ctr: Monolithic Pyramid Level 3 - Row 3 of 11  successfully built
  ----------
...................................
  ----------
    ctr: Monolithic Pyramid Level 3 - Row 10 of 11  successfully built
  ----------
    ctr: Monolithic Pyramid Level 3 - Row 11 of 11  successfully built
  ----------
    ctr: Monolithic Pyramid Level 4 - Row 1 of 6  successfully built
  ----------
    ctr: Monolithic Pyramid Level 4 - Row 2 of 6  successfully built
  ----------
    ctr: Monolithic Pyramid Level 4 - Row 3 of 6  successfully built
  ----------
    ctr: Monolithic Pyramid Level 4 - Row 4 of 6  successfully built
  ----------
    ctr: Monolithic Pyramid Level 4 - Row 5 of 6  successfully built
  ----------
    ctr: Monolithic Pyramid Level 4 - Row 6 of 6  successfully built
  ----------
    ctr: Monolithic Pyramid Level 5 - Row 1 of 3  successfully built
  ----------
    ctr: Monolithic Pyramid Level 5 - Row 2 of 3  successfully built
  ----------
    ctr: Monolithic Pyramid Level 5 - Row 3 of 3  successfully built
  ----------
    ctr: Monolithic Pyramid Level 6 - Row 1 of 2  successfully built
  ----------
    ctr: Monolithic Pyramid Level 6 - Row 2 of 2  successfully built
  ----------
    ctr: Monolithic Pyramid Level 7 - Row 1 of 1  successfully built
  ----------
    Monolithic Pyramid levels successfully built for: ctr

Operation PYRAMIDIZE-MONOLITHIC successfully completed
$
SELECT RL2_SetCoverageInfos('ctr', 'Topographical map (monochrome)', '1-bit (monochrome) topographical map')
Please remember: always setting a TITLE and an ABSTRACT for any Coverage being creates always is a strongly recommended good practice.

Step 5) Testing the Trento CTR sample

As you've already done in the previous Planet Earth you can now directly test the Trento 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 CTR #1

Trento CTR #2

Trento CTR #3

Please note: in the case of Monochrome Rasters RasterLite2 usually supports a wider range of high-quality rescaled images than many others similar tools.
This is because RasterLite2 always applies high quality interpolation algorithms while rescaling a Monochrome Raster; this way many halt-tone pixels are interpolated where appropriate so to preserve as much as possible crisp fine grained details.
The cost to pay for all this is a colorspace shift; all rescaled Pyramid Levels supporting a Monochrome Raster are implicitly of the grayscale type, thus requiring more storage space. It's a tradeof between quality and space.

Step 6) retrieving the Map layout

$ rl2tool MAP -db trento.sqlite -cov ctr  -outw 480 \
-outh 640 -dst trento-map.png

rl2_tool; request is MAP
===========================================================
           DB path: trento.sqlite
          Coverage: ctr
  Destination Path: trento-map.png
        Image Size: 512 x 640
===========================================================

     SQLite version: 3.8.5
 SpatiaLite version: 4.2.0-rc1
RasterLite2 version: 0.8

Operation MAP successfully completed
$
By invoking rl2tool MAP you can create a PNG image representing the overall Sections layout within a Coverage:
Trento CTR MAP

And this image corresponds to the actual output created by the above rl2tool MAP execution.

Step 7) creating and loading your own custom Monochrome Raster Styles

7.1) downloading the Monochrome styles

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

7.2) exploring the SLD/SE Monochrome RasterSymbolizer anatomy

<?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>monochrome_red</Name>
	<Description>
		<Title>Monochrome CTR Red</Title>
		<Abstract>Monochrome CTR: red instead of black</Abstract>
	</Description>
	<Opacity>1.0</Opacity>
	<ColorMap>
		<Categorize fallbackValue="#ffffff">
			<LookupValue>Rasterdata</LookupValue>
			<Value>#ffffff</Value>
			<Threshold>1</Threshold>
			<Value>#ff0000</Value>
		</Categorize>
	</ColorMap>
</RasterSymbolizer>
You've already got few basic notions about RasterSymbolizer during the previous Trieste, Orbetello and ETOPO-1 tutorials: now we'll examine how to apply a ColorMap to a Monochrome Raster:

7.3) importing all RasterSymbolizers into the DB-file

$ sqlite3 earth.sqlite
SQLite version 3.8.4.2 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('ctr',
   ...> XB_Create(XB_LoadXML('./monochrome_styles/monochrome_red.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('ctr',
   ...> XB_Create(XB_LoadXML('./monochrome_styles/monochrome_blue.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('ctr',
   ...> XB_Create(XB_LoadXML('./monochrome_styles/monochrome_yellow.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('ctr',
   ...> XB_Create(XB_LoadXML('./monochrome_styles/monochrome_slate.xml'), 1, 1));
1
sqlite> SELECT RegisterRasterStyledLayer('ctr',
   ...> XB_Create(XB_LoadXML('./monochrome_styles/monochrome_light_gray.xml'), 1, 1));
1
sqlite> .quit
$
This step exactly corresponds to the task already explained in the Trieste, Orbetello and ETOPO-1 tutorials.

Step 8) testing the Trento CTR sample (and playing with Styles)

Trento CTR Red
applying a Red hue: monochrome_red style.

Trento CTR Blue
applying a Blue hue: monochrome_blue style.
These first two examples could be probably interesting enough: but there is no real added value, just a may be pleasant graphics effect.

Trento CTR Slate
applying a Slate hue: monochrome_slate style.

Trento CTR Yellow
applying a Yellow hue: monochrome_yellow style.
These last two examples show the real reason behind Monochrome Raster Styles; Monochrome Raster are always intrinsically transparent, so you can overprint a Monochrome Raster on an other Raster background (in this case: RGB aerial orthophotos).
By applying an appropriate recoloring to the Monochrome Raster you'll then be able to ensure optimal readability of your complex maps; usually applying a very light/pale hue to the Monochrome Raster is the best possible option.



Back to RasterLite2 Tutorials index