point.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. .. _ysld_reference_symbolizers_point:
  2. Point symbolizer
  3. ================
  4. The point symbolizer is used to style point features or centroids of non-point features.
  5. Syntax
  6. ------
  7. The full syntax of a point symbolizer is::
  8. symbolizers:
  9. - point:
  10. symbols:
  11. - external:
  12. url: <text>
  13. format: <text>
  14. - mark:
  15. shape: <shape>
  16. fill-color: <color>
  17. fill-opacity: <expression>
  18. fill-graphic:
  19. <graphic_options>
  20. stroke-color: <color>
  21. stroke-width: <expression>
  22. stroke-opacity: <expression>
  23. stroke-linejoin: <expression>
  24. stroke-linecap: <expression>
  25. stroke-dasharray: <float list>
  26. stroke-dashoffset: <expression>
  27. stroke-graphic:
  28. <graphic_options>
  29. stroke-graphic-fill:
  30. <graphic_options>
  31. size: <expression>
  32. anchor: <tuple>
  33. displacement: <tuple>
  34. opacity: <expression>
  35. rotation: <expression>
  36. geometry: <expression>
  37. uom: <text>
  38. x-labelObstacle: <boolean>
  39. x-composite-base: <boolean>
  40. x-composite: <text>
  41. x-inclusion: <text>
  42. where:
  43. .. include:: include/stroke.rst
  44. .. include:: include/fill.rst
  45. .. list-table::
  46. :class: non-responsive
  47. :header-rows: 1
  48. :stub-columns: 1
  49. :widths: 20 10 50 20
  50. * - Property
  51. - Required?
  52. - Description
  53. - Default value
  54. * - ``external``
  55. - No
  56. - Specifies an image to use to style the point.
  57. - N/A
  58. * - ``url``
  59. - Yes
  60. - Location of the image. Can either be an actual URL or a file path (relative to where the style file is saved in the GeoServer data directory). Should be enclosed in single quotes.
  61. - N/A
  62. * - ``format``
  63. - Yes
  64. - Format of the image. Must be a valid MIME type (such as ``image/png`` for PNG, ``image/jpeg`` for JPG, ``image/svg+xml`` for SVG)
  65. - N/A
  66. * - ``mark``
  67. - No
  68. - Specifies a regular shape to use to style the point.
  69. - N/A
  70. * - ``shape``
  71. - No
  72. - Shape of the mark. Options are ``square``, ``circle``, ``triangle``, ``cross``, ``x``, and ``star``.
  73. - ``square``
  74. * - ``size``
  75. - No
  76. - Size of the mark in pixels. If the aspect ratio of the mark is not 1:1 (square), will apply to the *height* of the graphic only, with the width scaled proportionally.
  77. - 16
  78. * - ``anchor``
  79. - No
  80. - Specify the center of the symbol relative to the feature location. Value is an ``[x,y]`` tuple with decimal values from 0-1, with ``[0,0]`` meaning that the symbol is anchored to the top left, and ``[1,1]`` meaning anchored to bottom right.
  81. - ``[0.5,0.5]``
  82. * - ``displacement``
  83. - No
  84. - Specifies a distance to which to move the symbol relative to the feature. Value is an ``[x,y]`` tuple with values expressed in pixels, so [10,5] will displace the symbol 10 pixels to the right and 5 pixels down.
  85. - ``[0,0]``
  86. * - ``opacity``
  87. - No
  88. - Specifies the level of transparency. Value of ``0`` means entirely transparent, while ``1`` means entirely opaque. Only affects graphics referenced by the ``external`` parameter; the opacity of ``mark`` symbols is controlled by the ``fill-opacity`` and ``stroke-opacity`` of the mark.
  89. - ``1``
  90. * - ``rotation``
  91. - No
  92. - Value (in degrees) or rotation of the mark. Larger values increase counter-clockwise rotation. A value of ``180`` will make the mark upside-down.
  93. - ``0``
  94. .. include:: include/symbol.rst
  95. The following properties are equivalent to SLD "vendor options".
  96. .. include:: include/misc.rst
  97. Additional "vendor options" properties for :ref:`sld-extensions_composite-blend`:
  98. .. include:: include/composite.rst
  99. Additional "vendor options" properties for :ref:`rendering_selection`:
  100. .. include:: include/inclusion.rst
  101. Examples
  102. --------
  103. Basic point
  104. ~~~~~~~~~~~
  105. A point symbolizer draws a point at the center of any geometry. It is defined by an external image or a symbol, either of which can be sized and rotated. A mark is a pre-defined symbol that can be drawn at the location of a point. Similar to polygons, marks have both a fill and a stroke. This example shows a point symbolizer that draws semi-transparent red diamonds with black outlines::
  106. feature-styles:
  107. - name: name
  108. rules:
  109. - title: red point
  110. symbolizers:
  111. - point:
  112. symbols:
  113. - mark:
  114. shape: square
  115. fill-color: '#FF0000'
  116. fill-opacity: 0.75
  117. stroke-color: '#000000'
  118. stroke-width: 1.5
  119. stroke-opacity: 1
  120. size: 20
  121. rotation: 45
  122. .. figure:: img/point_basic.png
  123. Basic point
  124. Point as image
  125. ~~~~~~~~~~~~~~
  126. Sometimes it may be useful to use an image to represent certain points. This can be accomplished using the ``external`` symbol property, which requires a ``url`` and a ``format``. The ``url`` should be enclosed in single quotes. The ``format`` property is a `MIME type image <http://en.wikipedia.org/wiki/Internet_media_type#Type_image>`_. This example shows a point symbolizer that draws an image centered on each point::
  127. name: point
  128. feature-styles:
  129. - name: name
  130. rules:
  131. - symbolizers:
  132. - point:
  133. symbols:
  134. - external:
  135. url: 'geoserver.png'
  136. format: image/png
  137. size: 16
  138. .. figure:: img/point_graphic.png
  139. Point as image
  140. Point composition
  141. ~~~~~~~~~~~~~~~~~
  142. Using more than one point symbolizer allows the composition of more complex symbology. This example shows two symbolizers along with the ``x-composite`` parameter in order to *subtract* a shape from a square mark, allowing the background to show through.
  143. .. code-block:: yaml
  144. symbolizers:
  145. - point:
  146. symbols:
  147. - mark:
  148. shape: square
  149. fill-color: '#222222'
  150. size: 40
  151. - point:
  152. symbols:
  153. - external:
  154. url: 'stamp.png'
  155. format: image/png
  156. x-composite: xor
  157. size: 40
  158. .. figure:: img/point_composition.png
  159. Point composition
  160. Points as arrow heads
  161. ~~~~~~~~~~~~~~~~~~~~~
  162. Sometimes it is useful to generate a point using a CQL expression. The following example generates a point at the end of each line in the shape of an arrow, rotated such that it matches the orientation of the line.
  163. .. code-block:: yaml
  164. name: arrow
  165. symbolizers:
  166. - line:
  167. stroke-color: '#808080'
  168. stroke-width: 3
  169. - point:
  170. geometry: ${endPoint(the_geom)}
  171. symbols:
  172. - mark:
  173. shape: shape://oarrow
  174. fill-color: '#808080'
  175. size: 30
  176. rotation: ${endAngle(the_geom)}
  177. .. figure:: img/arrow.png
  178. Point as arrow head