I am trying to style an GeometryCollection geometry data type from PotGIS table in Geoserver. I have not found any examples on the Internet how to do it nor is it supported in Geoserver or not. When I try to style it using standard PolygonSymbolizer, LineSymbolizer and PointSymbolizer I get strange behaviours. For example, filled non-closed linestrings, non-exitsting points appear on linestring etc. This is one example of my SLD file and rendered WMS request.

Am I doing something wrong in my SLD?

Is GeometryCollection supported in Geoserver?

Example of SLD:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
            <ogc:Function name="geometryType">
              <CssParameter name="fill">#FF0000</CssParameter>
              <CssParameter name="stroke">#FFFFFF</CssParameter>
              <CssParameter name="stroke-width">6</CssParameter>
              <CssParameter name="fill">#00FF00</CssParameter>
              <CssParameter name="stroke-width">2</CssParameter>
              <CssParameter name="stroke-linejoin">round</CssParameter>
              <CssParameter name="stroke-linecap">round</CssParameter>
                    <CssParameter name="fill">#0000FF</CssParameter>

Rendered WMS request with provided SLD file:

Rendered WMS request with provided SLD file


What you are seeing is the correct behaviour as described by the SLD Spec. If you want to only apply one symbolizer to a feature then you need to provide a filter that selects one (or more) of the symbolizers for each feature.

The GeoServer documentation covers how to handle multiple geometries in one column quite clearly here.

  • Yes, I understand this, but I have geometrycollection which has points, lines and poligons, how can I select particular type from that geometrycollection object? Dec 9 '14 at 12:05
  • I might go to making views into PostGIS or SQL View layer in GeoServer for splitting GeometryCollections to point/multipoint, linestring/multilinestring, and polygon/multipolygon layers. Then the layers could be styled in a reasonable way and combined back together by making a WMS layer group. Very few software can style geometrycollections well. OpenJUMP is one that can but it does not help you with your web service.
    – user30184
    Dec 9 '14 at 12:21
  • easiest way is the filter on geometry type
    – Ian Turton
    Dec 9 '14 at 12:58
  • @user30184 I am aware of this approach, but I wanted to avoid it :) .. thank you for the suggestion Dec 9 '14 at 19:59
  • @iant if I filler by geometry type, I get geometry type geometrycollection ... what to with it then? With filtering by geometry type I do not get point, linestring and polygon. Dec 9 '14 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.