8

How can I force all labels to be visible in GeoServer

I have tried with both

<VendorOption name="conflictResolution">false</VendorOption>

and

<VendorOption name="spaceAround">-1</VendorOption>

But it doesn't seem to help much. The pointsymbolizer are always visible though. And sometimes it doesn't even feel like its "crouded" when the labels isn't visible.

enter image description here

The (I guess) interesting parts in my sld file looks like following:

<PointSymbolizer>
    <Graphic>
                     <Mark>
                       <WellKnownName>circle</WellKnownName>
                       <Fill>
                         <CssParameter name="fill">#FFFFFF</CssParameter>
                       </Fill>
                      <sld:Stroke>
                        <sld:CssParameter name="stroke">#9F0000</sld:CssParameter>
                        <sld:CssParameter name="stroke-width">2</sld:CssParameter>
                      </sld:Stroke>                           
                     </Mark>
                     <Size>9</Size>
                   </Graphic>
                 </PointSymbolizer>                    
                <TextSymbolizer>
                <sld:Geometry>
                  <ogc:Function name="centroid">
                    <ogc:PropertyName>geom</ogc:PropertyName>
                  </ogc:Function>
                </sld:Geometry>                    
                    <Label>
                      <ogc:PropertyName>label</ogc:PropertyName>
                    </Label>
                    <Font>
                      <CssParameter name="font-family">Arial</CssParameter>
                      <CssParameter name="font-weight">Bold</CssParameter>
                      <CssParameter name="font-size">14</CssParameter>
                    </Font>
                    <LabelPlacement>
                      <PointPlacement>
                        <AnchorPoint>
                          <AnchorPointX>0.5</AnchorPointX>
                          <AnchorPointY>0.5</AnchorPointY>
                        </AnchorPoint>
                        <Displacement>
                          <DisplacementX>0</DisplacementX>
                          <DisplacementY>-15</DisplacementY>
                        </Displacement>
                      </PointPlacement>
                    </LabelPlacement>
                    <Halo>
                      <Radius>
                        <ogc:Literal>2</ogc:Literal>
                      </Radius>
                      <Fill>
                        <CssParameter name="fill">#9F0000</CssParameter>
                      </Fill>
                    </Halo>
                    <Fill>
                      <CssParameter name="fill">#FFFFFF</CssParameter>
                    </Fill>
                    <VendorOption name="conflictResolution">false</VendorOption>

                </TextSymbolizer>
4
  • try goodnessOfFit with a small number <VendorOption name="goodnessOfFit">0.3</VendorOption>
    – Ralph Dell
    Aug 12, 2014 at 14:43
  • remember that GeoServer will not draw a label if it would fall off the edge of the map so when using small tiles labelling will probably not be optimal. Try using an untiled layer for your labels.
    – Ian Turton
    Aug 12, 2014 at 15:13
  • iant>Thank you very much, that solved it! I you like, create your comment as answer, and I will mark it as an correct answer.
    – Mike001
    Aug 13, 2014 at 5:49
  • Ralph Dell>Thanks for the response, I have tried that before and that didn't help either. But since I had a tiled layer I guess that it dont matter what I do in the sld
    – Mike001
    Aug 13, 2014 at 5:54

3 Answers 3

7

Label placement is more an art than a science, GeoServer tries very hard to put as many labels as possible on to your map while making it look good. As part of this it will not draw a label that goes over the edge of the map. This means that with small tiles and relatively large labels it may not be possible to place many (or any) labels. The easiest solution to this is to use an untiled layer with just the labels on which you overlay on top of your map. Since there is not much rendering involved in labeling this should not be too slow if it isn't cached.

You can also work round this using options such as gutters and meta-tiling depending on the exact situation if you must have tiles.

6

You can use :

<VendorOption name="partials">true</VendorOption>

to tell geoserver to render labels that are partially visible

3
  • I am using CSS styling with the same problem, any idea how to use "partials" vendor option in CSS style?
    – Brian B
    Dec 5, 2018 at 20:30
  • Have you tried partials: true; ?
    – Olyster
    Dec 6, 2018 at 14:05
  • I have not, tried that, however I did look at the code and see no support for "partials" in the CSS styling code.
    – Brian B
    Dec 7, 2018 at 14:13
1
<VendorOption name="conflictResolution">false</VendorOption>

&

<VendorOption name="goodnessOfFit">0</VendorOption>

Got the job done for me

1
  • This did the job for me. I was unaware that goodnessOfFit works at 0, which also doesn't make much sense.
    – Mathias
    Jun 22, 2023 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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