Elevation layers in templates: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
()
No edit summary
 
Line 54: Line 54:
   </layer></source>
   </layer></source>


== Elevation color map layers ==
Available since Maria GDK 4.0
Another use for elevation data is to make map layers colored according to some function of the terrain surface. Currently we support straight ''elevation'' color maps where each pixel is colored according to its elevation value, ''slope'' maps, where each pixel is colored according to its gradient or slope value, and ''aspect'' maps showing the direction of slope.
To make such a layer, set up a template layer with type <code>ElevationColorMapLayer</code> and a data source with map type <code>ElevationColorMap</code>. To control the analysis function and color palette, use the properties <code>elevation:analysisMode</code> and <code>elevation:paletteId</code>.
{| class="wikitable"
! Parameter
! Possible values
|-
| <code>elevation:analysisMode</code> || <code>elevation</code>, <code>slope</code>, <code>aspect</code>
|-
| <code>elevation:paletteId</code> || (name of palette to use)
|}
There are three built-in color palettes: <code>elevation</code>, <code>bathymetry</code> and <code>slope</code>, but more palettes can be added programmatically in your application or the templatelayer. See the documentation for TPG.GeoFramework.MapLayer.ElevationColorMapProvider for more details.
The following example sets up a slope layer.
<source lang="xml">  <layer type="ElevationColorMapLayer" name="Elevation Color Map">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>1</minscalevisible>
    <maxscalevisible>20000000</maxscalevisible>
    <datasource>
      <mapsignature>ElevationColorMap</mapsignature>
      <maptype>ElevationColorMap</maptype>
      <hostcategory>DontCare</hostcategory>
      <showlabels>false</showlabels>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
    <property key="labels:fetchdata" value="false" />
    <property key="elevation:analysisMode" value="slope" />
    <property key="elevation:paletteId" value="slope" />
  </layer></source>
=== Palettes in templates ===
Color palettes (one or multiple) can be defined in the ElevationColorMap template layer (see example below).
Use parameter <code>startrange</code> (default false) to divide the palette into multiple color ranges. Color ranges can be used to assign specific colors to specific elevationranges. The example below defines 4 ranges: everything below 0.0, elevations between 0.0 and 500.0, 500.0 and 1000.0, and everything over 1000.0. Each color range will be recalculated separately within its range.
Use parameter <code>autorounding</code> (default true) to achieve automatic rounding of elevation levels when recalculating colorsteps.
Example palettes:
<source lang="xml">
<layer type="ElevationColorMapLayer" name="Colormaptest">
<opacity>1</opacity>
<brightness>0</brightness>
<gamma>1</gamma>
<contrast>0</contrast>
<grayscale>false</grayscale>
<compression>Any</compression>
<minscalevisible>1</minscalevisible>
<maxscalevisible>20000000</maxscalevisible>
<datasource>
<mapsignature>Test Colormaps</mapsignature>
<maptype>ElevationColorMap</maptype>
<hostcategory>DontCare</hostcategory>
<showlabels>false</showlabels>
<usecache>false</usecache>
<colorpalette paletteid="test" analysismode="elevation" autorounding="false">
<color argb="#00000000" value="-300.0"/>
<color argb="#8001354D" value="-200.0"/>
<color argb="#80034865" value="-100.0"/>
<color argb="#8026809B" value="-50.0"/>
<color argb="#8070ACC6" value="-20.0"/>
<color argb="#80B7D3E8" value="-10.0"/>
<color argb="#80d0e5f5" value="0.0" startrange="true"/>
<color argb="#80246536" value="10.0"/>
<color argb="#80337E3A" value="25.0"/>
<color argb="#80459741" value="50.0"/>
<color argb="#805EB04E" value="100.0"/>
<color argb="#808ACA72" value="250.0"/>
<color argb="#80400000" value="500.0" startrange="true"/>
<color argb="#80800000" value="550.0"/>
<color argb="#80a00000" value="600.0"/>
<color argb="#80dc0000" value="650.0"/>
<color argb="#80f10000" value="750"/>
<color argb="#80CCDE94" value="1000.0" startrange="true"/>
<color argb="#80BBBF64" value="1250.0"/>
<color argb="#80A0903D" value="1500.0"/>
<color argb="#807F5A1E" value="2000.0"/>
<color argb="#80602907" value="3000.0"/>
</colorpalette>
<colorpalette paletteid="test-aspect" analysismode="aspect" autorounding="true" ignorerange="true">
<color argb="#b4d0e5f5" value="-1.0"/>
<color argb="#B4FFDAB9" value="0.0"/>
<color argb="#B4FFE4B5" value="30.0"/>
<color argb="#B4BC8F8F" value="60.0"/>
<color argb="#B4D2B48C" value="90.0"/>
<color argb="#B4F4A460" value="120.0"/>
<color argb="#B4CD853F" value="150.0"/>
<color argb="#B4D2691E" value="180.0"/>
<color argb="#B4A0522D" value="210.0"/>
<color argb="#B48B4513" value="240.0"/>
<color argb="#B4B0C4DE" value="270.0"/>
<color argb="#B4E6E6FA" value="300.0"/>
<color argb="#B4FFE4E1" value="330.0"/>
</colorpalette>
</datasource>
<property key="elevation:paletteId" value="test" />
<visible>true</visible>
<property key="labels:fetchdata" value="false" />
</layer>
</source>
Note: Parameters startrange and autorounding are available since Maria GDK 4.1.


== Elevation data layers ==
== Elevation data layers ==
Line 202: Line 86:
   </layer>
   </layer>
</source>
</source>


[[Category:Map configuration]]
[[Category:Map configuration]]

Latest revision as of 13:47, 3 January 2022

Elevation data can be referenced and visualized in various ways in Maria GDK. This can be done programmatically by the application, or in the template XML files.

Hill shading layers

Available since Maria GDK 3.1.

Pre-generated hill shading

Data referenced in this layer type is generated with the TPG tool

<layer type="ModLayer" name="Normalmapelevations" category="ElevEffects">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>244</minscalevisible>
    <maxscalevisible>128000000</maxscalevisible>
    <description>Elevation shading layer based on prerendered normal maps</description>
    <datasource>
      <mapsignature>norway_normals20m</mapsignature>
      <maptype>RasterMap</maptype>
      <showlabels>true</showlabels>
      <usecache>true</usecache>
    </datasource>
    <visible>true</visible>
  </layer>

On-the-fly hill shading

If you have elevation data active in the application you can generate the hill shading automatically on the fly. To do this, add a ModLayer as above, but with an "ElevationNormals" maptype data source. The map signature value is not significant.

  <layer type="ModLayer" name="Auto shading" category="ElevEffects">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>1</minscalevisible>
    <maxscalevisible>2000000</maxscalevisible>
    <datasource>
      <mapsignature>AutoShading</mapsignature>
      <maptype>ElevationNormals</maptype>
      <showlabels>false</showlabels>
      <usecache>false</usecache>
    </datasource>
    <shadingparameters>
        <ambient>0.6</ambient>
    </shadingparameters>
    <visible>true</visible>
    <property key="labels:fetchdata" value="false" />
  </layer>


Elevation data layers

Templates can also be used to define a set of elevation data layers used for analysis purposes, such as elevation profiles etc.

These elevation layers are processed in the order they appear in the template file, in such a manner that the first layer that returns a valid result is used. This means that you typically want to place datasets with higher resolution and smaller area first in the file. If your query falls within the high resolution subdataset, you will get result from these data, and if not, it will fall through to the next layer which may for example be a global base elevation grid.

These templates are typically set programmatically through the IElevationData interface.

In the following example, we have a 10m resolution elevation data set that covers Norway first in the template, and a global SRTM dataset as fallback.

  <layer type="ElevationLayer" name="Norge 10m">
    <compression>Any</compression>
    <datasource>
      <mapsignature>elevation10m</mapsignature>
      <maptype>ElevationData</maptype>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
  </layer>

  <layer type="ElevationLayer" name="SRTM30">
    <compression>Any</compression>
    <datasource>
      <mapsignature>globe_elevation</mapsignature>
      <maptype>ElevationData</maptype>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
  </layer>