raster.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. .. _ysld_reference_symbolizers_raster:
  2. Raster symbolizer
  3. =================
  4. The raster symbolizer styles raster (coverage) layers. A raster is an array of information with each cell in the array containing one or more values, stored as "bands".
  5. The full syntax of a raster symbolizer is::
  6. symbolizers:
  7. - raster:
  8. opacity: <expression>
  9. channels:
  10. gray:
  11. <channel_options>
  12. red:
  13. <channel_options>
  14. green:
  15. <channel_options>
  16. blue:
  17. <channel_options>
  18. color-map:
  19. type: <ramp|interval|values>
  20. entries:
  21. - [color, entry_opacity, band_value, text_label]
  22. contrast-enhancement:
  23. mode: <normalize|histogram>
  24. gamma: <expression>
  25. x-inclusion: <text>
  26. where:
  27. .. list-table::
  28. :class: non-responsive
  29. :header-rows: 1
  30. :stub-columns: 1
  31. :widths: 20 10 50 20
  32. * - Property
  33. - Required?
  34. - Description
  35. - Default value
  36. * - ``opacity``
  37. - No
  38. - Opacity of the entire display. Valid values are a decimal between ``0`` (completely transparent) and ``1`` (completely opaque).
  39. - ``1``
  40. * - ``channels``
  41. - No
  42. - Selects the band(s) to display and the display method.
  43. - N/A
  44. * - ``gray``
  45. - No
  46. - Display a single band as a grayscale image. Cannot be used with ``red``, ``green``, and ``blue``. The ``<channel_options>`` can be the band name or a mapping containing ``name:`` and ``contrast-enhancement:`` (optional).
  47. - ``1``
  48. * - ``red``
  49. - No
  50. - Display three bands as an RGB image. Must be used with ``green``, and ``blue``. Cannot be used with ``gray``. The ``<channel_options>`` can be the band name or a mapping containing ``name:`` and ``contrast-enhancement:`` (optional).
  51. - ``1``
  52. * - ``green``
  53. - No
  54. - Display three bands as an RGB image. Must be used with ``red``, and ``blue``. Cannot be used with ``gray``. The ``<channel_options>`` can be the band name or a mapping containing ``name:`` and ``contrast-enhancement:`` (optional).
  55. - ``2``
  56. * - ``blue``
  57. - No
  58. - Display three bands as an RGB image. Must be used with ``red``, and ``green``. Cannot be used with ``gray``. The ``<channel_options>`` can be the band name or a mapping containing ``name:`` and ``contrast-enhancement:`` (optional). See examples below.
  59. - ``3``
  60. * - ``color-map``
  61. - No
  62. - Creates a mapping of colors to grid values. Can only be used with a single band.
  63. - N/A
  64. * - ``type``
  65. - No
  66. - Type of color mapping. Options are ``ramp``, an interpolated list of values; ``interval``, a non-interpolated list of values; and ``values``, where values need to match exactly to be drawn.
  67. - ``ramp``
  68. * - ``entries``
  69. - No
  70. - Values for the color mapping. Syntax is a list of tuples.
  71. - N/A
  72. * - ``color``
  73. - Yes
  74. - Color for the particular color map entry. Value is a standard color value.
  75. - N/A
  76. * - ``entry_opacity``
  77. - Yes
  78. - Opacity of the particular color map entry. Valid values are a decimal between ``0`` (completely transparent) and ``1`` (completely opaque).
  79. - N/A
  80. * - ``band_value``
  81. - Yes
  82. - Grid value to use for the particular color map entry. Values are data-dependent. Behavior at or around this value is determined by the color ramp ``type``.
  83. - N/A
  84. * - ``text_label``
  85. - No
  86. - Label for the particular color map entry
  87. - Blank
  88. * - ``contrast-enhancement``
  89. - No
  90. - Modifies the contrast of the display
  91. - N/A
  92. * - ``mode``
  93. - No
  94. - Type of contrast enhancement. Options are ``normalize`` (stretches contrast so that the smallest and largest values are set to black and white, respectively) or ``histogram`` (produces equal number of content in the image at each brightness level).
  95. - ``normalize``
  96. * - ``gamma``
  97. - No
  98. - Multiplier value for contrast adjustment. A value greater than 1 will increase darkness, while a value less than 1 will decrease darkness.
  99. - ``1``
  100. Additional "vendor options" properties for :ref:`sld-extensions_composite-blend`:
  101. .. include:: include/composite.rst
  102. Additional "vendor options" properties for :ref:`rendering_selection`:
  103. .. include:: include/inclusion.rst
  104. Examples
  105. --------
  106. .. todo:: All examples need figures
  107. Enhanced contrast
  108. ~~~~~~~~~~~~~~~~~
  109. This example takes a given raster and lightens the output by a factor of 2::
  110. symbolizers:
  111. - raster:
  112. contrast-enhancement:
  113. gamma: 0.5
  114. .. figure:: img/raster_brightness.png
  115. Lightened image
  116. Normalized output
  117. ~~~~~~~~~~~~~~~~~
  118. This example takes a given raster and adjusts the contrast so that the smallest values are darkest and the highest values are lightest::
  119. symbolizers:
  120. - raster:
  121. contrast-enhancement:
  122. mode: normalize
  123. .. figure:: img/raster_normalize.png
  124. Normalized image
  125. Band selection
  126. ~~~~~~~~~~~~~~
  127. This example takes a raster with multiple bands and outputs band 2 as a grayscale image (This could be used to select a single band in a multi-band image to use with ``color-map``)::
  128. name: raster
  129. feature-styles:
  130. - name: name
  131. rules:
  132. - symbolizers:
  133. - raster:
  134. opacity: 1.0
  135. channels:
  136. gray: 2
  137. .. figure:: img/raster_band_gray.png
  138. Grayscale band selection
  139. Band selection with contrast
  140. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  141. This example takes an RGB raster, doubles the intensity of the red, and normalizes the green band::
  142. name: raster
  143. feature-styles:
  144. - name: name
  145. rules:
  146. - symbolizers:
  147. - raster:
  148. channels:
  149. red:
  150. name: 1
  151. contrast-enhancement:
  152. gamma: .5
  153. green:
  154. name: 2
  155. contrast-enhancement:
  156. mode: normalize
  157. blue:
  158. name: 3
  159. .. figure:: img/raster_band_contrast.png
  160. Band selection with contrast enhancement
  161. Color ramp
  162. ~~~~~~~~~~
  163. This example shows a color ramp from red to green to blue, with raster band values from 0-200::
  164. symbolizers:
  165. - raster:
  166. color-map:
  167. type: ramp
  168. entries:
  169. - ['#FF0000', 1, 0, red]
  170. - ['#00FF00', 1, 100, green]
  171. - ['#0000FF', 1, 200, blue]
  172. In this example, the grid values will have the following colors applied:
  173. * Less than or equal to 0 will have an output color of **solid red**
  174. * Between 0 and 100 will have an output color **interpolated between red and green**
  175. * Between 100 and 200 will have an output color **interpolated between green and blue**
  176. * Greater than 200 will have an output color of **solid blue**
  177. .. figure:: img/raster_map_ramp.png
  178. Color map with ramp
  179. Color intervals
  180. ~~~~~~~~~~~~~~~
  181. The same example as above, but with the ``color-map`` type set to ``intervals``::
  182. symbolizers:
  183. - raster:
  184. color-map:
  185. type: intervals
  186. entries:
  187. - ['#FF0000', 1, 0, red]
  188. - ['#00FF00', 1, 100, green]
  189. - ['#0000FF', 1, 200, blue]
  190. In this example, the grid values will have the following colors applied:
  191. * Less than or equal to 0 will have an output color of **solid red**
  192. * Between 0 and 100 will have an output color of **solid green**
  193. * Between 100 and 200 will have an output color of **solid blue**
  194. * Greater than 200 will **not be colored** at all (transparent)
  195. .. figure:: img/raster_map_intervals.png
  196. Color map with intervals
  197. Color values
  198. ~~~~~~~~~~~~
  199. The same example as above, but with the ``color-map`` type set to ``values``::
  200. symbolizers:
  201. - raster:
  202. color-map:
  203. type: values
  204. entries:
  205. - ['#FF0000', 1, 0, red]
  206. - ['#00FF00', 1, 100, green]
  207. - ['#0000FF', 1, 200, blue]
  208. In this example, the grid values will have the following colors applied:
  209. * Equal to 0 will have an output color of **solid red**
  210. * Equal to 100 will have an output color of **solid green**
  211. * Equal to 200 will have an output color of **solid blue**
  212. Any other values (even those in between the above values) will not be colored at all.
  213. .. figure:: img/raster_map_values.png
  214. Color map with values