index.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. .. _ncwms:
  2. ncWMS WMS extensions support
  3. ============================
  4. The **ncWMS module** adds to GeoServer the ability to support some of the ncWMS extensions to the WMS protocol and configuration.
  5. In particular:
  6. * Ability to create a named style by simply providing a list of colors, that will adapt to the layer in use based on request parameters and its statistics
  7. * Ability to control the palette application in GetMap via a number of extra parameters
  8. * GetTimeSeries operation, which can retrieve a CSV or an xy chart of a time series of values on a certain point
  9. At the time of writing the extra calls to extract elevation series, transects and NetCDF metadata are not supported.
  10. The extension is however not NetCDF specific, but can be used with any single banded raster layer instead.
  11. The Dynamic Palette style format
  12. --------------------------------
  13. A new "Dynamic palette" style format has been added that accepts a palette, one color per line, defining a color progression to be applied on raster data.
  14. Each color can be defined using these possible syntaxes (same as ncWMS):
  15. * ``#RRGGBB``
  16. * ``#AARRGGBB``
  17. * ``0xRRGGBB``
  18. * ``0xAARRGGBB``
  19. Comments can be added in the file by starting the line by a percentage sign. For example, a red to blue progression might look like::
  20. % Red to blue progression
  21. #FF0000
  22. #0000FF
  23. .. figure:: images/redblue-editor.png
  24. :align: center
  25. *Configuring a dynamic palette style*
  26. Several ready to use palettes coming from the popular "color brewer" site are available in the `ncWMS source code repository <https://github.com/Reading-eScience-Centre/edal-java/tree/master/graphics/src/main/resources/palettes>`_.
  27. The palette translates on the fly into a SLD with rendering transformation using the :ref:`community_colormap` module, in particular,
  28. the above style translates to the following style:
  29. .. code-block:: xml
  30. :linenos:
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
  33. <sld:NamedLayer>
  34. <sld:Name/>
  35. <sld:UserStyle>
  36. <sld:Name/>
  37. <sld:FeatureTypeStyle>
  38. <sld:Transformation>
  39. <ogc:Function name="ras:DynamicColorMap">
  40. <ogc:Function name="parameter">
  41. <ogc:Literal>data</ogc:Literal>
  42. </ogc:Function>
  43. <ogc:Function name="parameter">
  44. <ogc:Literal>opacity</ogc:Literal>
  45. <ogc:Function name="env">
  46. <ogc:Literal>OPACITY</ogc:Literal>
  47. <ogc:Literal>1.0</ogc:Literal>
  48. </ogc:Function>
  49. </ogc:Function>
  50. <ogc:Function name="parameter">
  51. <ogc:Literal>colorRamp</ogc:Literal>
  52. <ogc:Function name="colormap">
  53. <ogc:Literal>rgb(255,0,0);rgb(0,0,255)</ogc:Literal>
  54. <ogc:Function name="env">
  55. <ogc:Literal>COLORSCALERANGE_MIN</ogc:Literal>
  56. <ogc:Function name="bandStats">
  57. <ogc:Literal>0</ogc:Literal>
  58. <ogc:Literal>minimum</ogc:Literal>
  59. </ogc:Function>
  60. </ogc:Function>
  61. <ogc:Function name="env">
  62. <ogc:Literal>COLORSCALERANGE_MAX</ogc:Literal>
  63. <ogc:Function name="bandStats">
  64. <ogc:Literal>0</ogc:Literal>
  65. <ogc:Literal>maximum</ogc:Literal>
  66. </ogc:Function>
  67. </ogc:Function>
  68. <ogc:Function name="env">
  69. <ogc:Literal>BELOWMINCOLOR</ogc:Literal>
  70. <ogc:Literal>rgba(0,0,0,0)</ogc:Literal>
  71. </ogc:Function>
  72. <ogc:Function name="env">
  73. <ogc:Literal>ABOVEMAXCOLOR</ogc:Literal>
  74. <ogc:Literal>rgba(0,0,0,0)</ogc:Literal>
  75. </ogc:Function>
  76. <ogc:Function name="env">
  77. <ogc:Literal>LOGSCALE</ogc:Literal>
  78. <ogc:Literal>false</ogc:Literal>
  79. </ogc:Function>
  80. <ogc:Function name="env">
  81. <ogc:Literal>NUMCOLORBANDS</ogc:Literal>
  82. <ogc:Literal>254</ogc:Literal>
  83. </ogc:Function>
  84. </ogc:Function>
  85. </ogc:Function>
  86. </ogc:Function>
  87. </sld:Transformation>
  88. <sld:Rule>
  89. <sld:RasterSymbolizer/>
  90. </sld:Rule>
  91. </sld:FeatureTypeStyle>
  92. </sld:UserStyle>
  93. </sld:NamedLayer>
  94. </sld:StyledLayerDescriptor>
  95. The above explains a bit of how the palette is applied:
  96. * By default a palette of 254 colors is generated between a min and max value, plus one color for anything below the minimum and another for anything above the maximum
  97. * It is possible to pass the minimum and maximum values using the GetMap ``env`` parameter, if not provided, they are fetched from the configured band statistics (as found in the layer configuration)
  98. * The overall opacity of the palette can be controlled (using a value between 0 and 1 to conform with the SLD opacity description)
  99. * The scale can be either linear, or logarithmic
  100. .. figure:: images/bandrange.png
  101. :align: center
  102. *Editing the defaults for min/max scale range values in the GeoServer layer editor*
  103. The above parameters can all be used at will to control the palette generation using the typical environment variable approach. However, it's also possible to use ncWMS own extensions, which
  104. are adding direct parameters in the request. See the following section for details.
  105. ncWMS GetMap extensions
  106. -----------------------
  107. This module also adds a dynamic translator taking the ncWMS GetMap vendor parameters and mapping them to the dynamic palette expectations. In particular (copying the parameter description
  108. from the ncWMS manual, with GeoServer specific annotations):
  109. * COLORSCALERANGE: Of the form min,max this is the scale range used for plotting the data (mapped to the COLORSCALERANGE_MIN and COLORSCALERANGE_MAX env vars)
  110. * NUMCOLORBANDS: The number of discrete colours to plot the data. Must be between 2 and 250 (mapped to the NUMCOLORBANDS env variable)
  111. * ABOVEMAXCOLOR: The colour to plot values which are above the maximum end of the scale range. Colours are of the form 0xRRGGBB or 0xAARRGGBB, and it also accepts "transparent" and "extend"
  112. * BELOWMINCOLOR: The colour to plot values which are below the minimum end of the scale range. Colours are of the form 0xRRGGBB or 0xAARRGGBB, and it also accepts "transparent" and "extend"
  113. * LOGSCALE: "true" or "false" - whether to plot data with a logarithmic scale
  114. * OPACITY: The percentage opacity of the final output image as a number between 0 and 100 (maps to OPACITY env var by translating it to a number between 0 and 1)
  115. * ANIMATION: "true" or "false" - whether to generate an animation. The ncWMS documentation states that TIME has to be of the form ``starttime/endtime``,
  116. but currently TIME needs to be a list of discrete times instead. Animation requires using the "image/gif" as the response format (as the only format supporting animation)
  117. Here are a few examples based on the "ArcSample" arcgrid sample layer, containing annual precipitation data. The one band provided by this layer has been configured with a default range of 0 to 6000.
  118. * Default output with the "redblue" palette:
  119. http://localhost:8080/geoserver/wms?STYLES=redblue&LAYERS=nurc%3AArc_Sample&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-180,-90,180,90&WIDTH=500&HEIGHT=250
  120. .. figure:: images/redblue-default.png
  121. :align: center
  122. * Adopting a logarithmic scale by adding ``&COLORSCALERANGE=1,6000&LOGSCALE=true`` (a logarithmic scale needs a positive minimum)
  123. .. figure:: images/redblue-logscale.png
  124. :align: center
  125. * Using just 5 colors in logarithmic mode by adding ``&COLORSCALERANGE=1,6000&LOGSCALE=true&NUMCOLORBANDS=5``
  126. .. figure:: images/redblue-numcolors.png
  127. :align: center
  128. * Limiting the range and specifying other colors above (gray) and below (yellow) by adding ``&COLORSCALERANGE=100,2000&BELOWMINCOLOR=0xFFFF00&ABOVEMAXCOLOR=0xAAAAAA``
  129. .. figure:: images/redblue-range.png
  130. :align: center
  131. ncWMS GetCapabilities extensions
  132. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  133. ncWMS allows users to filter the contents of a capabilities document by adding a ``&dataset=datasetName`` parameter to the request.
  134. While GeoServer does not have a concept of dataset, the ncWMS extension allows to use the same parameter to filter on workspaces, layers and layer groups, by name.
  135. For example:
  136. * Getting everything in the "topp" workspace: http://localhost:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities&dataset=topp
  137. * Getting only the "topp:states" layer: http://localhost:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities&dataset=topp:states
  138. * Getting the "tasmania" layer group: http://localhost:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities&dataset=tasmania
  139. ncWMS GetTimeSeries operation
  140. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  141. ncWMS provides a GetTimeSeries operation, which can retrieve a time series of values on a certain point, using a syntax similar to the GetFeatureInfo operation.
  142. The time series can be retrieved as a chart in PNG or JPEG image, or as a CSV.
  143. For example:
  144. * Getting a time series as CSV: http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetTimeSeries&FORMAT=image%2Fjpeg&TIME=2008-10-31T00:00:00.000Z/2008-11-01T00:00:00.000Z&QUERY_LAYERS=watertemp&STYLES&LAYERS=watertemp&INFO_FORMAT=text%2Fcsv&FEATURE_COUNT=50&X=50&Y=50&SRS=EPSG%3A4326&WIDTH=101&HEIGHT=101&BBOX=3.724365234375%2C40.81420898437501%2C5.943603515625%2C43.03344726562501
  145. * Getting a time series as PNG: http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetTimeSeries&FORMAT=image%2Fjpeg&TIME=2008-10-31T00:00:00.000Z/2008-11-01T00:00:00.000Z&QUERY_LAYERS=watertemp&STYLES&LAYERS=watertemp&INFO_FORMAT=image%2Fpng&FEATURE_COUNT=50&X=50&Y=50&SRS=EPSG%3A4326&WIDTH=101&HEIGHT=101&BBOX=3.724365234375%2C40.81420898437501%2C5.943603515625%2C43.03344726562501
  146. * Getting a time series as JPG: http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetTimeSeries&FORMAT=image%2Fjpeg&TIME=2008-10-31T00:00:00.000Z/2008-11-01T00:00:00.000Z&QUERY_LAYERS=watertemp&STYLES&LAYERS=watertemp&INFO_FORMAT=image%2Fjpg&FEATURE_COUNT=50&X=50&Y=50&SRS=EPSG%3A4326&WIDTH=101&HEIGHT=101&BBOX=3.724365234375%2C40.81420898437501%2C5.943603515625%2C43.03344726562501
  147. The INFO_FORMAT accepts the following values: `image/png`, `image/jpg` and `text/csv`
  148. The TIME parameter accepts a time range as defined for other operations in the WMS standard (see Annex D of the 06-042 Web Map Server Implementation Specification). Examples:
  149. * `TIME=2008-10-31T00:00:00.000Z/2008-11-01T00:00:00.000Z`
  150. * `TIME=2008-10-31T00:00:00.000Z/2008-10-31T00:00:00.000Z`
  151. Since GeoServer 2.17, TIME parameter also supports 2 additional syntax even if not expressly supported by ncWMS specification:
  152. #. A List of Times:
  153. * Example: `TIME=2014-01,2015-01,2016-01,2017-01,2018-01`
  154. * Example: `TIME=2017-01-01T00:00:00Z,2017-02-01T00:00:00Z,2017-01-03T00:00:00Z`
  155. #. A periodic time within a range:
  156. * Example: `TIME=2015-01/2019-01/P1Y`
  157. .. note::
  158. * Shortened time specifications in a list are parsed as time ranges by GeoServer. Therefore, a Time like 2014-01 will represent the whole month of January 2014, so a time range: 2014-01-01T00:00:00/2014-01-31T23:59:59.
  159. * Months and Years expressed through a Period specification (as an instance P2M, P1Y) are considered made of 30 days and 365.25 days respectively. Therefore a periodic interval like 2000-04/2000-12/P1M will be parsed as the list of time instants starting from April 2000 through December 2000 with a period of 30 days:
  160. * Apr 01 00:00:00 2000
  161. * May 01 00:00:00 2000
  162. * May **31** 00:00:00 2000
  163. * Jun **30** 00:00:00 2000
  164. * Jul **30** 00:00:00 2000
  165. * Aug **29** 00:00:00 2000
  166. * Sep **28** 00:00:00 2000
  167. * Oct **28** 00:00:00 2000
  168. * Nov **27** 00:00:00 2000
  169. * Dec **27** 00:00:00 2000
  170. * Therefore if your original dataset has an entry for the first day of each month, this request will only return 2 values: Apr 01 and May 01. In that case, you might consider enabling nearest match on Layer's time dimension.
  171. Sample CSV output:
  172. .. code-block:: none
  173. # Latitude: 40.396728515625
  174. # Longitude: -0.6921386718750019
  175. Time (UTC),Temperature (degrees)
  176. 2014-01-01T00:00:00.000Z,0.4194810092449188
  177. 2014-02-01T00:00:00.000Z,0.8373379707336426
  178. 2014-03-01T00:00:00.000Z,3.1670899391174316
  179. 2014-04-01T00:00:00.000Z,4.932330131530762
  180. Sample chart output:
  181. .. figure:: images/geoserver-GetTimeSeries.png
  182. :align: center
  183. **Note:** Since GeoServer 2.17, nodata pixels will not be reported in the result chart. Moreover, entries in CSV list related to nodata pixels will report time but will have no pixel value reported, as in the example below for times 2014-02-01 and 2014-05-01:
  184. .. code-block:: none
  185. # Latitude: 40.396728515625
  186. # Longitude: -0.6921386718750019
  187. Time (UTC),Temperature (degrees)
  188. 2014-01-01T00:00:00.000Z,0.4194810092449188
  189. 2014-02-01T00:00:00.000Z,
  190. 2014-03-01T00:00:00.000Z,3.1670899391174316
  191. 2014-04-01T00:00:00.000Z,4.932330131530762
  192. 2014-05-01T00:00:00.000Z,
  193. 2014-06-01T00:00:00.000Z,0.8373379707336426
  194. ncWMS extension configuration
  195. -----------------------------
  196. The ncWMS extension adds a panel at the bottom of the WMS administration page:
  197. .. figure:: images/admin.png
  198. :align: center
  199. .. list-table::
  200. :widths: 20 80
  201. :header-rows: 1
  202. * - Option
  203. - Description
  204. * - GetTimeSeries thread pool size
  205. - Size of the thread pool used to compute GetTimeSeries results (parallelized to speed up computation)
  206. * - Maximum number of times in GetTimeSeries
  207. - Maximum number of times tha GetTimeSeries will process. A user asking for more times will get back a service exception.
  208. The configuration is set the first time the admin hits save in the WMS page, even with a value of 0 (from that
  209. point on, GetTimeSeries will be independent on the WMS max dimensions setting).