Wiki page
[Sample Planet Earth] by
sandro
2020-09-12 17:30:05.
D 2020-09-12T17:30:05.459
L Sample\sPlanet\sEarth
P 300fb3e88cefc9a32ff47e606864dd39e3bb546f
U sandro
W 20469
<h1>Quick How-To Guide for the Planet Earth sample</h1>
In this tutorial we'll assume that you've already studied and understood the tutorials about the <b>Giglio sample</b><br>
Now we'll examine the <b>Planet Earth sample</b> which will allow us to delve further into new details that we previously ignored.
<br><br>
The following table summarizes for quick reference all Coverages contained into the <b>Planet Earth</b> sample database:<br><br>
<table border="1" bgcolor="f0fff0" cellpadding="8" cellspacing="4">
<tr><th bgcolor="#d0d0d0">Coverage name</td><td bgcolor="#d0d0d0">Type</th><th bgcolor="#d0d0d0">Description</th></tr>
<tr><td>etopo1</td><td bgcolor="#f0c0a0">Raster</td><td>Global DEM - Digital Elevation Model</td></tr>
<tr><td>true_marble</td><td bgcolor="#f0c0a0">Raster</td><td>Natural colors - RGB low-resolution mosaic of Landsat imagery</td></tr>
<tr><td>countries</td><td bgcolor="#a0c0f0">Vector</td><td>2D Polygons - National Boundaries</td></tr>
<tr><td>countries_vw</td><td bgcolor="#a0c0f0">Vector</td><td>Spatial View derived from <b>countries</b></td></tr>
<tr><td>topo_states</td><td bgcolor="#a0c0f0">Vector</td><td>Topology derived from <b>countries</b></td></tr>
</table>
<br><br>
All datasets are based on <b><i>open data</i></b> available at the following URLs:
<ul>
<li><b>ETOPO1</b>: <a href="https://www.ngdc.noaa.gov/mgg/global/">NOAA</a></li>
<li><b>True Marble</b>: <a href="https://academictorrents.com/details/b9b284d9c0074846fee28e78aac4440fd7c0f51c">Unearthed Outdoors</a></li>
<li><b>Countries</b>: <a href="https://www.naturalearthdata.com/">Natural Earth</a></li>
</ul>
<br><br><hr><br><br>
<table width="100%" border="1" bgcolor="ffffe8" cellpadding="8" cellspacing="4">
<tr><th bgcolor="#c0ffc0" colspan="2"><h1>Step #1 - General Introduction</h1></th></tr>
<tr><td>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
In this first contact with <b>Planet Earth</b> we'll simply test the basic rendering capabilities of the Map.<br><br>
You are simply expected to test the <b>pan</b> and <b>zoom</b> tools while switching on and off the various map layers.
</td></tr></table>
<br><hr>
<h3>Step #1.1 - Testing the ETOPO1 background</h3>
The side figure shows how the Map will be when applying the following layers selection:
<ul>
<li><b>ETOPO1</b> background</li>
<li><b>Countries</b> (<i>National Boundaries - red lines</i>) with labels corresponding to each Nation.
<ul>
<li><b>Note</b>: labels will be printed only if they fit inside the <b>MBR</b> of the corresponding <b>Polygon</b></li>
</ul></li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig_ex_dem.png" alt="fig_ex_dem">
</td></tr>
<tr><td>
<h3>Step #1.2 - Testing the True Marble background</h3>
The side figure shows how the Map will be when applying the following layers selection:
<ul>
<li><b>True Marble</b> background</li>
<li><b>Countries</b> (same as above).
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig_ex_tm.png" alt="fig_ex_tm">
</td></tr>
<tr><td>
<h3>Step #1.3 - Testing the Political Map</h3>
The side figure shows how the Map will be when applying the following layers selection:
<ul>
<li><b>Countries (view)</b> background
<ul>
<li><b>Note</b>: Each Country is internally filled with a different color, in such a way that confining Nations will never share the same color.</li>
</ul></li>
<li><b>Countries</b> (same as above).
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig_ex_pol.png" alt="fig_ex_pol">
</td></tr>
<tr><td>
<h3>Step #1.4 - Testing the Topology</h3>
The side figure shows how the Map will be when applying the following layers selection:
<ul>
<li><b>topo_states (Topology)</b> alone. All Topology Primitives are represented as follows:
<ul>
<li><b>Nodes</b>: red circles.</li>
<li><b>Edges</b>: blue lines.</li>
<li><b>Faces</b>: pale yellow polygons.</li>
<li><b>Face Seeds</b>: yellow stars.</li>
<li><b>Edge Seeds</b>: yellow diamonds.</li>
</ul></li>.
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig_ex_topo.png" alt="fig_ex_topo">
</td></tr>
<tr><th bgcolor="#c0ffc0" colspan="2"><h1>Step #2 - Preparing the Raster Coverages</h1></th></tr>
<tr><th bgcolor="#d0ffff" colspan="2"><h3>Step #2.1 - Creating the Raster Coverages</h3></th></tr>
<tr><td>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
<h4>Useful hint</h4>
Both <b>etopo1</b> and <b>true_marble</b> will be imported from a single GeoTiff.
Using the <b>tiffinfo CLI tool</b> so to check the internal configuration of the input images is warmly recommended.
</td></tr></table>
<br><hr><br>
<h3>Step #2.1.1 - Creating etopo_1</h3>
<ul>
<li>Set sensible values tof <b>Name</b>, <b>Title</b> and <b>Abstract</b>.</li>
<li>This one is a <b>DEM</b>, and the most appropriate settings are as follows:
<ul>
<li><u><i>Pixel Type</i></u> set to <b>DataGrid</b></li>
<li><u><i>Sample Type</i></u> set to <b>INT16</b></li>
<li><u><i>Compression Type</i></u> set to <b>LZMA</b></li>
<li><u><i>NO-DATA</i></u> set to <b>-9999</b></li>
<li><u><i>SRID</i></u> set to <b>4326</b></li>
<li><u><i>Pixel Resolution</i></u> set to <b>0.016666...</b></li>
<li>The <u><i>Strict Resolution Policy</i></u> has been selected.</li>
</ul>
</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig1.png" alt="fig1">
</td></tr>
<tr><td>
<h3>Step #2.1.2 - Creating true_marble</h3>
<ul>
<li>Set sensible values tof <b>Name</b>, <b>Title</b> and <b>Abstract</b>.</li>
<li>This one is a <b>RGB</b> image, so the most appropriate settings are as follows:
<ul>
<li><u><i>Pixel Type</i></u> set to <b>RGB</b></li>
<li><u><i>Sample Type</i></u> set to <b>UINT8</b></li>
<li><u><i>Compression Type</i></u> set to <b>JPEG2000</b> (because it's a rather slow codec, but it preserves a good visual quality at very high compression ratios).</li>
<li><u><i>Quality</i></u> set to <b>5</b> (so to ensure a very good compression ratio without sacrificing too much the visual quality).</li>
<li><u><i>NO-DATA</i></u> set to <b>NONE</b></li>
<li><u><i>SRID</i></u> set to <b>4326</b></li>
<li><u><i>Pixel Resolution</i></u> set to <b>0.016666...</b></li>
<li>The <u><i>Strict Resolution Policy</i></u> has been selected.</li>
</ul>
</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig3.png" alt="fig3">
</td></tr>
<tr><th bgcolor="#d0ffff" colspan="2"><h3>Step #2.2 - Populating the Raster Coverages</h3></th></tr>
<tr><td>
On the dialog box:
<ul>
<li>Remember to enable the <b>Immediately build Section Pyramids</b> checkbox</li>
</ul>
<br><hr><br>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
This recipe is valid for both <b>etopo1</b> and <b>true_marble</b>
<br><br>
<b>Note</b>: in this case you should absolutely avoid to select the <b>Forced SRID value</b> and/or <b>With WorldFile support</b> checkbox because we are importing from <b>GeoTiff</b> that internally stores any required information.
</td></tr></table>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig2.png" alt="fig2">
</td></tr>
<tr><th bgcolor="#d0ffff" colspan="2"><h3>Step #2.3 - Styling the Raster Coverages</h3></th></tr>
<tr><td>
<b>etopo1</b> is Global DEM, presenting elevation values ranging between the ocean depths and the very high peaks of the Himalayas.<br>
The most appropriate choice for the <b>Color Map Style</b> could be either <b>Etopo2</b> or <b>SRTM</b> or <b>Terrain</b>.
<br><hr><br>
<b>Note</b>: setting up a Style for <b>true_marble</b> is not required, because this one is a <b>RGB</b> Coverage, and the <b>default</b> Style will be perfectly adequate.
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig33.png" alt="fig33">
</td></tr>
<tr><th bgcolor="#c0ffc0" colspan="2"><h1>Step #3 - Preparing the Vector Coverages</h1></th></tr>
<tr><th bgcolor="#d0ffff" colspan="2"><h3>Step #3.1 - Styling countries (Spatial Table)</h3></th></tr>
<tr><td>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
This recipe is valid for both <b>etopo1</b> and <b>true_marble</b>
<br><br>
There is very little to say about creating and populating the <b>countries</b> Spatial Table, because we'll just import the <b>Shapefile</b> downloaded from <b>Natural Earth</b>.<br><br>
Then transforming this Spatial Table into a corresponding Vector Coverage should be a trivial task; if you have doubts about this passage you just have to return to the previous tutorial.<br><br>
So we'll focus out attention just on the Style, that is a little bit more elaborate then usual.
</td></tr></table>
<br><hr><br>
<h3>Step #3.1.1 - Setting up the Polygon Symbolizer</h3>
On the <b>QuickStyle</b> Dialog Box:
<ul>
<li>open the <b>Polygon Symbolizer</b> tab.</li>
<li>be sure to <b>disable</b> the <b>Fill</b> option.</li>
<li>enable the <b>Stroke</b> option.
<ul>
<li><b>Note</b>: this way we'll get <b>hollow polygons</b>, completely lacking any internal filling, so to preserve fully visible the underlaying Raster.</li>
</ul></li>
<li>and finally press the <b>Ok</b> button so to confirm.</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig31.png" alt="fig31">
</td></tr>
<tr><td>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
We've not yet finished.<br>
Now we'll add a <b>second Symbolizer</b> to the current Style, and it will exactly be a <b>Text Symbolizer</b><br><br>
This way each polygon will have the name of the corresponding Nation printed on its surface.
</td></tr></table>
<br><hr><br>
<h3>Step #3.1.2 - Setting up the Text Symbolizer</h3>
On the <b>QuickStyle</b> Dialog Box:
<ul>
<li>open the <b>Text Symbolizer</b> tab.</li>
<li>be sure to enable the <b>Labels</b> option.</li>
<li>select from the list the name of the <b>Column</b> containing the values to printed as labels (in this case <b>name</b>).</li>
<li>Choose some <b>Font</b> from the list
<ul>
<li><b>Note</b>: all fonts accessible to <b>RasterLite2</b> must be stored into the <b>SE_fonts</b> table.<br>
You'll find some user friendly wizards making easier handling Fonts in the context menu associated to the <b>Styling (SLD/SE)</b> node on the Tree Control.<br>
Few <b>Toy Fonts</b> are always available because they are directly embedded in the code.</li>
</ul></li>
<li>Set an appropriate <b>Font Size</b> and select the <b>Bold</b> option for better readability.</li>
<li>Enable the <b>Font Halo</b> option and specifiy a very thin <b>Radius</b>
<ul>
<li><b>Note</b>: for what concerns <b>Colors</b> we've set <b>white text</b> surrounded by a narrow <b>black</b> halo so to unsure a good readability on every background.</li>
</ul></li>
<li>and finally press the <b>Ok</b> button so to confirm.</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig32.png" alt="fig32">
</td></tr>
<tr><th bgcolor="#d0ffff" colspan="2"><h3>Step #3.2 - Creating and styling a Vector Coverage based on a Spatial View</h3></th></tr>
<tr><td>
<h3>Step #3.2.1 - Creating the Spatial View</h3>
There is very little to say about this; we simply have to execute a pair of SQL statements.<br><br>
What is decisely more interesting to be examined is the intended role of the <b>CASE</b> clause:
<ul>
<li>if you quicly examine the <b>countries</b> table you'll discover the presence of a Column named <b>mapcolor7</b></li>
<li>as you can easily check, all values in this column range from <b>1</b> to <b>7</b></li>
<li><b>Short conclusion</b>: that <b>mapcolor7</b> column is specifically intended to contain <b>color indices</b> allowing to easily style a Political Map of the World.</li>
<li>So in our View we simply have to transform each <b>color index</b> into a corresponding <b>HTML hex color</b>, and exactely this is the intended scope of the <b>CASE</b> clause.</li>
</ul>
</td><td>
<verbatim>
CREATE VIEW countries_vw AS
SELECT pk_uid AS rowid, name AS name,
CASE mapcolor7
WHEN 1 THEN '#FF0000'
WHEN 2 THEN '#00FF00'
WHEN 3 THEN '#0000FF'
WHEN 4 THEN '#FFFF00'
WHEN 5 THEN '#FF00FF'
WHEN 6 THEN '#00FFFF'
ELSE '#808080'
END color, geometry AS geom
FROM countries;
INSERT INTO views_geometry_columns VALUES
('countries_vw', 'geom', 'rowid', 'countries', 'geometry', 1);
</verbatim>
</td></tr>
<tr><td>
<h3>Step #3.2.2 - Transforming a Spatial View into a Vector Coverage</h3>
From the Tree View expand the <b>Spatial View</b> node, then go to its <b>Geometry</b> node:
<ul>
<li>press the <b><i>mouse right button</i></b></li>
<li>a context menu will be displayed on the screen</li>
<li>Click the <b>Create Vector Coverage</b> menu item</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig4.png" alt="fig4">
</td></tr>
<tr><td>
<table bgcolor="#ffd080" cellpadding="14"><tr><td>
<b>Note</b>: the Style we'll go to create is not directly supported by any wizard; it strictly requires to be hand-written.<br>
Don't be afraid because it will be extremely simple and easy.
<ol>
<li>first of all use the <b>QuickStyles</b> wizard in order to create a generic <b>Polygon symbolizer</b></li>
<li>then <b>export</b> the XML code into an external file.</li>
<li>and finally open a <b>text editor</b> whatsoever so to manually complete the Style.</li>
</ol>
</td></tr></table>
<br><hr><br>
<h3>Step #3.2.3 - Styling the countries_vw Vector Coverage</h3>
How to edit the XML template:
<ul>
<li>you'll start as usual by setting appropriate values to <b>Name</b>, <b>Title</b> and <b>Abstract</b></li>
<li>now you just are required to set the <b>fill parameter</b> as <b>@color@</b>
<ul>
this one is a <b>special notation</b> (not supported by standard SLD/SE specifications), intending that <b>RasterLite2</b> will find the actual value to be used into the Column of the current feature whose name matches the string enclosed between the two <b>@...@</b> markers.</li>
</ul></li>
</ul>
</td><td>
<pre>
<?xml version="1.0" encoding="UTF-8"?>
<PolygonSymbolizer 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"
uom="http://www.opengeospatial.org/se/units/pixel">
<Name><font color="red" size="+2"><b>countries_col</b></font></Name>
<Description>
<Title><font color="red" size="+2"><b>Countries - Political Map</b></font></Title>
<Abstract><font color="red" size="+2"><b>A Style setting its Fill color from a Column Value</b></font></Abstract>
</Description>
<Fill>
<SvgParameter name="fill"><font color="red" size="+2"><b>@color@</b></font></SvgParameter>
<SvgParameter name="fill-opacity">1.00</SvgParameter>
</Fill>
<Stroke>
<SvgParameter name="stroke">#000000</SvgParameter>
<SvgParameter name="stroke-opacity">1.00</SvgParameter>
<SvgParameter name="stroke-width">1.00</SvgParameter>
<SvgParameter name="stroke-linejoin">round</SvgParameter>
<SvgParameter name="stroke-linecap">round</SvgParameter>
</Stroke>
</PolygonSymbolizer>
</pre>
</td></tr>
</td></tr>
<tr><th bgcolor="#d0ffff" colspan="2"><h3>Step #3.3 - Creating and styling a Vector Coverage based on a Topology</h3></th></tr>
<tr><td>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
<h4>Useful hint</h4>
If you ignore absolutely everything about <b>Topology</b> perhaps it would be advisable that you read the <a href="https://www.gaia-gis.it/fossil/libspatialite/wiki?name=ISO+Topology">documentation</a> first.<br><br>
</td></tr></table>
<br><hr><br>
<h3>Step #3.3.1 - How to create a Topology</h3>
From the <b>Topology-Geometry</b> node in the Tree View:
<ul>
<li>press the <b><i>mouse right button</i></b></li>
<li>a context menu will be displayed on the screen</li>
<li>Click the <b>Create New Topology-Geometry</b> menu item</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig5.png" alt="fig5">
</td></tr>
<tr><td>
<h3>Step #3.3.2 - Creating the Topology</h3>
On the dialog box:
<ul>
<li>set a <b>Topology Name</b></li>
<li>set an appropriate <b>SRID</b></li>
<li>select <b>2D</b> dimensions</li>
<li>set <b>Tolerance</b> to zero</li>
<li>and finally press the <b>Create</b> button in order to confirm</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig6.png" alt="fig6">
</td></tr>
<tr><td>
<h3>Step #3.3.3 - Building the Topology</h3>
There is very little to say, it just requires executing few SQL statements.
</td><td>
<verbatim>
SELECT TopoGeo_FromGeoTableNoFaceExt('topo_states', NULL, 'countries', NULL, 'dustbin', 'dustbin_view', 512);
SELECT TopoGeo_Polygonize('topo_states');
SELECT TopoGeo_UpdateSeeds('topo_states');
</verbatim>
</td></tr>
<tr><td>
<h3>Step #3.3.4 - Transforming a Topology into a Vector Coverage</h3>
From the <b>Topology-Geometry</b> node in the Tree View:
<ul>
<li>expand the node so to make all Topologies visible
<ul>
<li>from the child node corresponding to the intended Topology:
<ul>
<li>press the <b><i>mouse right button</i></b></li>
<li>a context menu will be displayed on the screen</li>
<li>Click the <b>Create Topology Coverage</b> menu item</li>
</ul></li>
</ul></li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig7.png" alt="fig7">
</td></tr>
<tr><td>
<table bgcolor="#80ffd0" cellpadding="14"><tr><td>
A Vector Coverage based on some Topology is someway exceptional, because it groups several different classes of <b>Primitives</b>:
<ul>
<li><b>Nodes</b></li>
<li><b>Edges</b></li>
<li><b>Faces</b></li>
<li><b>Face Seeds</b></li>
<li><b>Edge Seeds</b></li>
</ul>
<br>
<ol>
<li>Each one of them requires a specific Symbolizer.</li>
<li>All them will be switched on and off at the same time, because all them are considered as parts of the same layer.</li>
<li><b>Conclusion</b>: the handling of Topology-based Coverages is someway exceptional, and requires special precautions.</li>
</ol>
<br>
<b>Note</b>: more or less the same applies to <b>Network</b>-based Coverages (that will not be illustrated in any tutorial).
</td></tr></table>
<br><hr><br>
<h3>Step #3.3.5 - Handling a Topology-based Vector Coverage</h3>
From the <b>main.topo_states</b> node in the Tree View:
<ul>
<li>press the <b><i>mouse right button</i></b></li>
<li>a context menu will be displayed on the screen</li>
<li>Both the <b>Configure</b> and <b>QuickStyles Edit</b> menu items influences the behavior of this Coverage</li>
</ul>
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig77.png" alt="fig7">
</td></tr>
<tr><td>
<h3>Step #3.3.6 - Handling the visibily of individual Topology Primitives</h3>
On the <b>Configuration</b> Dialog Box you can select / unselect the checkbox corresponding to each single <b>Primitive</b><br>
Any disabled Privitive class will never be shown on the Map.
<br><br>
<b>Note</b>: the <b>Faces Primitive</b> is usually kept disabled, because Topology Faces are simply <b>virtual</b> thus being very slow to be generated on the fly.<br>
If the current viewpoint of the Map contains a reasonable number of Faces showing them could be acceptable.<br>
But when the current viepoint contains a really huge number of Faces updating the Map will probably require an absolutely unacceptable time. You are warned, be very careful.
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig9.png" alt="fig9">
</td></tr>
<tr><td>
<h3>Step #3.3.7 - Styling a Topology-based Vector Coverage</h3>
Styling a Topology-based Coverage isn't at all difficult, it's just a little bit more complex than usual because you are required to define 5 different Symbolizers, one for each Primitive.
</td><td>
<img src="https://www.gaia-gis.it/gaia-sins/MapPanelPics/PlanetEarth/fig8.png" alt="fig8">
</td></tr>
</table>
Z a6030f0fdaff8bea89fbf77d605192e3