pointsymbolizer.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. .. _sld_reference_pointsymbolizer:
  2. PointSymbolizer
  3. ===============
  4. A **PointSymbolizer** styles features as **points**.
  5. Points are depicted as graphic symbols at a single location on the map.
  6. Syntax
  7. ------
  8. A ``<PointSymbolizer>`` contains an optional ``<Geometry>`` element,
  9. and a required ``<Graphic>`` element specifying the point symbology.
  10. .. list-table::
  11. :widths: 20 20 60
  12. * - **Tag**
  13. - **Required?**
  14. - **Description**
  15. * - ``<Geometry>``
  16. - No
  17. - Specifies the geometry to be rendered.
  18. * - ``<Graphic>``
  19. - Yes
  20. - Specifies the styling for the point symbol.
  21. Geometry
  22. ^^^^^^^^
  23. The ``<Geometry>`` element is optional.
  24. If present, it specifies the featuretype property from which to obtain the geometry to style
  25. using a ``<PropertyName>`` element.
  26. See also :ref:`geometry_transformations` for GeoServer extensions for specifying geometry.
  27. Any kind of geometry may be styled with a ``<PointSymbolizer>``.
  28. For non-point geometries, a representative point is used (such as the centroid of a line or polygon).
  29. .. _sld_reference_graphic:
  30. Graphic
  31. ^^^^^^^
  32. Symbology is specified using a ``<Graphic>`` element.
  33. The symbol is specified by either an ``<ExternalGraphic>`` or a ``<Mark>`` element.
  34. **External Graphics** are image files (in a format such as PNG or SVG) that contain the shape and color information defining how to render a symbol.
  35. **Marks** are vector shapes whose stroke and fill are defined explicitly in the symbolizer.
  36. There are five possible sub-elements of the ``<Graphic>`` element.
  37. One of ``<ExternalGraphic>`` or ``<Mark>`` must be specified; the others are optional.
  38. .. list-table::
  39. :widths: 20 20 60
  40. * - **Tag**
  41. - **Required?**
  42. - **Description**
  43. * - ``<ExternalGraphic>``
  44. - No (when using ``<Mark>``)
  45. - Specifies an external image file to use as the symbol.
  46. * - ``<Mark>``
  47. - No (when using ``<ExternalGraphic>``)
  48. - Specifies a named shape to use as the symbol.
  49. * - ``<Opacity>``
  50. - No
  51. - Specifies the opacity (transparency) of the symbol.
  52. Values range from ``0`` (completely transparent) to ``1`` (completely opaque).
  53. Value may contain :ref:`expressions <sld_reference_parameter_expressions>`.
  54. Default is ``1`` (opaque).
  55. * - ``<Size>``
  56. - No
  57. - Specifies the size of the symbol, in pixels.
  58. When used with an image file, this specifies the height of the image, with the width being scaled accordingly.
  59. if omitted the native symbol size is used.
  60. Value may contain :ref:`expressions <sld_reference_parameter_expressions>`.
  61. * - ``<Rotation>``
  62. - No
  63. - Specifies the rotation of the symbol about its center point, in decimal degrees.
  64. Positive values indicate rotation in the clockwise direction,
  65. negative values indicate counter-clockwise rotation.
  66. Value may contain :ref:`expressions <sld_reference_parameter_expressions>`.
  67. Default is ``0``.
  68. ExternalGraphic
  69. ^^^^^^^^^^^^^^^
  70. **External Graphics** are image files (in formats such as PNG or SVG) that contain the shape and color information defining how to render a symbol.
  71. For GeoServer extensions for specifying external graphics, see :ref:`pointsymbols`.
  72. The ``<ExternalGraphic>`` element has the sub-elements:
  73. .. list-table::
  74. :widths: 20 20 60
  75. * - **Tag**
  76. - **Required?**
  77. - **Description**
  78. * - ``<OnlineResource>``
  79. - Yes
  80. - The ``xlink:href`` attribute specifies the location of the image file.
  81. The value can be either a URL or a local pathname relative to the SLD directory.
  82. The value can contain CQL expressions delimited by ``${ }``.
  83. The attribute ``xlink:type="simple"`` is also required.
  84. The element does not contain any content.
  85. * - ``<Format>``
  86. - Yes
  87. - The MIME type of the image format.
  88. Most standard web image formats are supported.
  89. Common MIME types are ``image/png``, ``image/jpeg``, ``image/gif``, and ``image/svg+xml``
  90. Mark
  91. ^^^^
  92. **Marks** are predefined vector shapes identified by a well-known name.
  93. Their fill and stroke can be defined explicitly in the SLD.
  94. For GeoServer extensions for specifying mark symbols, see :ref:`pointsymbols`.
  95. The ``<Mark>`` element has the sub-elements:
  96. .. list-table::
  97. :widths: 20 20 60
  98. * - **Tag**
  99. - **Required?**
  100. - **Description**
  101. * - ``<WellKnownName>``
  102. - No
  103. - The name of the shape.
  104. Standard SLD shapes are ``circle``, ``square``, ``triangle``, ``star``, ``cross``, or ``x``. Default is ``square``.
  105. * - ``<Fill>``
  106. - No
  107. - Specifies how the symbol should be filled (for closed shapes).
  108. Options are to use ``<CssParameter name="fill">`` to specify a solid fill color, or using ``<GraphicFill>`` for a tiled graphic fill.
  109. See the ``PolygonSymbolizer`` :ref:`sld_reference_fill` for the full syntax.
  110. * - ``<Stroke>``
  111. - No
  112. - Specifies how the symbol linework should be drawn.
  113. Some options are using ``<CssParameter name="stroke">`` to specify a stroke color, or using ``<GraphicStroke>`` for a repeated graphic.
  114. See the ``LineSymbolizer`` :ref:`sld_reference_stroke` for the full syntax.
  115. Example
  116. -------
  117. The following symbolizer is taken from the :ref:`sld_cookbook_points` section in the :ref:`sld_cookbook`.
  118. .. code-block:: xml
  119. :linenos:
  120. <PointSymbolizer>
  121. <Graphic>
  122. <Mark>
  123. <WellKnownName>circle</WellKnownName>
  124. <Fill>
  125. <CssParameter name="fill">#FF0000</CssParameter>
  126. </Fill>
  127. </Mark>
  128. <Size>6</Size>
  129. </Graphic>
  130. </PointSymbolizer>
  131. The symbolizer contains the required ``<Graphic>`` element.
  132. Inside this element is the ``<Mark>`` element and ``<Size>`` element, which are the minimum required element inside ``<Graphic>`` (when not using the ``<ExternalGraphic>`` element).
  133. The ``<Mark>`` element contains the ``<WellKnownName>`` element and a ``<Fill>`` element.
  134. No other element are required. In summary, this example specifies the following:
  135. #. Features will be rendered as points
  136. #. Points will be rendered as circles
  137. #. Circles will be rendered with a diameter of 6 pixels and filled with the color red
  138. The next example uses an external graphic loaded from the file system:
  139. .. code-block:: xml
  140. :linenos:
  141. <PointSymbolizer>
  142. <Graphic>
  143. <ExternalGraphic>
  144. <OnlineResource xlink:type="simple"
  145. xlink:href="file:///var/www/htdocs/sun.png" />
  146. <Format>image.png</Format>
  147. </ExternalGraphic>
  148. </Graphic>
  149. </PointSymbolizer>
  150. For ``file://`` URLs, the file must be readable by the user the GeoServer process is running as. You can also use ``href://`` URLs to reference remote graphics.
  151. Further examples can be found in the :ref:`sld_cookbook_points` section of the :ref:`sld_cookbook`.
  152. .. _sld_reference_parameter_expressions:
  153. Using expressions in parameter values
  154. -------------------------------------
  155. Many SLD parameters allow their values to be of **mixed type**.
  156. This means that the element content can be:
  157. * a constant value expressed as a string
  158. * a :ref:`filter expression <sld_filter_expression>`
  159. * any combination of strings and filter expressions.
  160. Using expressions in parameter values provides the ability to determine styling dynamically
  161. on a per-feature basis,
  162. by computing parameter values from feature properties.
  163. Using computed parameters is an alternative to using rules
  164. in some situations,
  165. and may provide a more compact SLD document.
  166. GeoServer also supports using substitution variables provided in WMS requests.
  167. This is described in :ref:`sld_variable_substitution`.