Color map layers in templates: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:
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.
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.


A template can be defined with an ID and referenced with the <code>colormap:paletteId</code>. These palette IDs are global in the system, so using GUID's in the paletteID is strongly recommended. In a template, the PaletteID can be omitted if there is only one palette defined in the color map layer.
A template can be defined with an ID and referenced with the <code>colormap:paletteId</code>. These palette IDs are global in the system, so using GUID's in the paletteID is strongly recommended.  


=== Palettes in templates ===
=== Palettes in templates ===
Line 86: Line 86:
</colorpalette>
</colorpalette>
</datasource>
</datasource>
<property key="elevation:paletteId" value="test" />
<property key="colormap:paletteId" value="test" />
<visible>true</visible>
<visible>true</visible>
<property key="labels:fetchdata" value="false" />
<property key="labels:fetchdata" value="false" />
Line 117: Line 117:
     <property key="labels:fetchdata" value="false" />
     <property key="labels:fetchdata" value="false" />
     <property key="elevation:analysisMode" value="slope" />
     <property key="elevation:analysisMode" value="slope" />
     <property key="elevation:paletteId" value="slope" />
     <property key="colormap:paletteId" value="slope" />
   </layer></source>
   </layer></source>


The next example sets up a clutter data set with a data provider and an inline palette definitiion:
The next example sets up a clutter data set with a data provider:


<source lang="xml">  
<source lang="xml">  
Line 141: Line 141:
         <maptype>ColorMap</maptype>
         <maptype>ColorMap</maptype>
         <mapprovider>clutterdata-9008D162-EB84-4853-BBDB-82CFE1D42B76</mapprovider>
         <mapprovider>clutterdata-9008D162-EB84-4853-BBDB-82CFE1D42B76</mapprovider>
         <colorpalette analysismode="value">
         <colorpalette paletteid="clutterdata-9008D162" analysismode="value">
             <color argb="#80d0e5f5" value="0" startrange="true"/>
             <color argb="#80d0e5f5" value="0" startrange="true"/>
             <color argb="#80246536" value="1"/>
             <color argb="#80246536" value="1"/>
Line 147: Line 147:
             <color argb="#807F5A1E" value="14"/>
             <color argb="#807F5A1E" value="14"/>
         </colorpalette>
         </colorpalette>
        <property key="resampling" value="nearest"/>
       </datasource>
       </datasource>
      <property key="colormap:paletteId" value="clutterdata-9008D162" />
      <property key="resampling" value="nearest"/>
      <property key="labels:fetchdata" value="false" />
       <visible>true</visible>
       <visible>true</visible>
      <property key="labels:fetchdata" value="false" />
   </layer>
   </layer>
</compositemaptemplate>0
</compositemaptemplate>0

Revision as of 15:03, 6 January 2022

Color map layers

Available since Maria GDK 4.0

We also provider functions to make map layers colored according to some function of a single channel input data set, typically elevation data, but this can also be used on other input data sets such as census, clutter, etc. 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 ColorMapLayer and a data source with map type ElevationColorMap or ColorMap. To control the analysis function and color palette, use the properties elevation:analysisMode and colormap:paletteId. To control the input data you can specify a data set through the mapprovider tag.

Parameter Possible values
elevation:analysisMode value, elevation (same as value), slope, aspect
colormap:paletteId (name of palette to use)

There are three built-in color palettes: elevation, bathymetry and slope, but more palettes can be added programmatically in your application or the templatelayer. See the documentation for TPG.GeoFramework.MapLayer.ElevationColorMapProvider for more details.

A template can be defined with an ID and referenced with the colormap:paletteId. These palette IDs are global in the system, so using GUID's in the paletteID is strongly recommended.

Palettes in templates

Color palettes (one or multiple) can be defined in the ElevationColorMap template layer (see example below).

Use parameter startrange (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 autorounding (default true) to achieve automatic rounding of elevation levels when recalculating colorsteps.

Example palettes:

	<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="colormap:paletteId" value="test" />
		<visible>true</visible>
		<property key="labels:fetchdata" value="false" />
	</layer>

Note: Parameters startrange and autorounding are available since Maria GDK 4.1.

Examples

The following example sets up a slope layer.

  <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="colormap:paletteId" value="slope" />
  </layer>

The next example sets up a clutter data set with a data provider:

 
<compositemaptemplate id="9008D162-EB84-4853-BBDB-82CFE1D42B76" name="Clutter">
   ...
   <dataprovider id="clutterdata-9008D162-EB84-4853-BBDB-82CFE1D42B76" type="GenericData" >
      <mapdatafilter signature="norkring_clutter25_asc_068714fe2b6f"/>
   </dataprovider>
   <layer type="ColorMapLayer" name="ClutterTestColorMap">
      <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>Clutter Colormap</mapsignature>
         <maptype>ColorMap</maptype>
         <mapprovider>clutterdata-9008D162-EB84-4853-BBDB-82CFE1D42B76</mapprovider>
         <colorpalette paletteid="clutterdata-9008D162" analysismode="value">
            <color argb="#80d0e5f5" value="0" startrange="true"/>
            <color argb="#80246536" value="1"/>
            ...
            <color argb="#807F5A1E" value="14"/>
         </colorpalette>
      </datasource>
      <property key="colormap:paletteId" value="clutterdata-9008D162" />
      <property key="resampling" value="nearest"/>
      <property key="labels:fetchdata" value="false" />
      <visible>true</visible>
   </layer>
</compositemaptemplate>0