1

I have GeoServer with raster (GeoTIFF) of the temperature parameter. Using SLD styles and bicubic interpolation I get nice map and now I'm trying to create a style that show the isolines. Color-Map

The isoline are displayed but the result is not what I expect. In fact while zooming in the lines become "straight"

Current Result: enter image description here

My current SLD is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
 xmlns="http://www.opengis.net/sld"
 xmlns:ogc="http://www.opengis.net/ogc"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- a Named Layer is the basic building block of an SLD document -->
  <NamedLayer>
        <Name>Temperature Isoline</Name>
        <UserStyle>
        <!-- Styles can have names, titles and abstracts -->
          <Title>Default Line</Title>
          <!-- FeatureTypeStyles describe how to render different features -->
          <!-- A FeatureTypeStyle for rendering lines -->
          <FeatureTypeStyle>
                <Transformation>
                  <ogc:Function name="gs:Contour">
                    <ogc:Function name="parameter">
           
                       <ogc:Literal>data</ogc:Literal>
                    </ogc:Function>
                        <ogc:Function name="parameter">
                          <ogc:Literal>levels</ogc:Literal>
                          <ogc:Literal>-50</ogc:Literal>
                          <ogc:Literal>-45</ogc:Literal>
                          <ogc:Literal>-30</ogc:Literal>
                          <ogc:Literal>-25</ogc:Literal>
                          <ogc:Literal>-20</ogc:Literal>
                          <ogc:Literal>-15</ogc:Literal>
                          <ogc:Literal>-10</ogc:Literal>
                          <ogc:Literal>-5</ogc:Literal>
                          <ogc:Literal>0</ogc:Literal>
                          <ogc:Literal>5</ogc:Literal>
                          <ogc:Literal>10</ogc:Literal>
                          <ogc:Literal>15</ogc:Literal>
                          <ogc:Literal>20</ogc:Literal>
                          <ogc:Literal>25</ogc:Literal>
                          <ogc:Literal>30</ogc:Literal>
                          <ogc:Literal>35</ogc:Literal>
                          <ogc:Literal>40</ogc:Literal>
                          <ogc:Literal>45</ogc:Literal>
                          <ogc:Literal>50</ogc:Literal>
                          <ogc:Literal>60</ogc:Literal>
                          <ogc:Literal>70</ogc:Literal>
                          <ogc:Literal>80</ogc:Literal>
                          <ogc:Literal>90</ogc:Literal>
                          <ogc:Literal>100</ogc:Literal>
                        </ogc:Function>
                  </ogc:Function>
                  
                </Transformation>

                <Rule>
                  <Name>rule1</Name>
                  <Title>Blue Line</Title>
                  <Abstract>A solid blue line with a 1 pixel width</Abstract>
                  <LineSymbolizer>
                        <Stroke>
                          
                          <CssParameter name="stroke">#0000FF</CssParameter>
                          <CssParameter name="stroke-linejoin">round</CssParameter>
                          <CssParameter name="stroke-linecap">round</CssParameter>
                        </Stroke>
                  </LineSymbolizer>
                  <TextSymbolizer>
                  <Label>
                        <ogc:PropertyName>value</ogc:PropertyName>
                  </Label>

                  <Font>
                        <CssParameter name="font-family">Arial</CssParameter>
                        <CssParameter name="font-style">Normal</CssParameter>
                        <CssParameter name="font-size">10</CssParameter>
                  </Font>

                  <LabelPlacement>
                        <LinePlacement>
                        </LinePlacement>
                  </LabelPlacement>
                  <Halo>
                        <Radius>
                          <ogc:Literal>2</ogc:Literal>
                        </Radius>
                        <Fill>
                          <CssParameter name="fill">#FFFFFF</CssParameter>
                          <CssParameter name="fill-opacity">0.85</CssParameter>
                        </Fill>
                  </Halo>

                  <Fill>
                        <CssParameter name="fill">#000000</CssParameter>
                  </Fill>

                  <VendorOption name="followLine">true</VendorOption>
                  <VendorOption name="repeat">200</VendorOption>
                  <VendorOption name="maxDisplacement">50</VendorOption>
                  <VendorOption name="maxAngleDelta">30</VendorOption>
                    <VendorOption name="group">no</VendorOption>

                </TextSymbolizer>
                </Rule>
          </FeatureTypeStyle>
        </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

What can I do?

2 Answers 2

2

The isolines extraction just follows the shape of the pixels... the raster map is low resolution, you're displaying it as a smooth map by enabling bicubic interpolation (so you're making up an appearance, but the data is not really there).

But the contour extraction process does not interpolate, uses the data as is. Try enabling smoothing, it might help with the visual appearance:

<ogc:Function name="parameter">
     <ogc:Literal>smooth</ogc:Literal>
     <ogc:Literal>true</ogc:Literal>
</ogc:Function>

That said, if pixels are that big, a smoothed out output is nice looking, but also just a lie, you're trying to display data you don't really have. If the output has any scientific value, I would suggest disabling countour lines display before you reach the zoom level where "blocky" output begins to show.

3
  • Hi @Andrea, the smooth didn't fix the issue. I was also trying to use Barnes surface, trying to use the <ogc:Function name="gs:RasterAsPointCollection"> as data, but as i'm new with SLD. I'm going crazy. What else i can do to try fixing this bad looking? Commented Jan 5, 2021 at 13:06
  • 1
    Debug the code until you can get it fixed, and then contribute the changes back to GeoTools? That's what I would do at least, cannot think of an easier way. Commented Jan 5, 2021 at 15:16
  • I Finally Got it!! see my answer Commented Jan 21, 2021 at 21:02
0

I Finally found a solution. It was easier than I thought I had to add the <ogc:Function name="Interpolate"> in the .

The results now looks like: enter image description here

My SDL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <!-- a Named Layer is the basic building block of an SLD document -->
    <NamedLayer>
        <Name>default_line</Name>
        <UserStyle>
            <!-- Styles can have names, titles and abstracts -->
            <Title>Default Line</Title>
            <Abstract>A sample style that draws a line</Abstract>
            <!-- FeatureTypeStyles describe how to render different features -->
            <!-- A FeatureTypeStyle for rendering lines -->
            <FeatureTypeStyle>
                <Transformation>
                    <ogc:Function name="gs:Contour">
                        <ogc:Function name="parameter">
                            <ogc:Literal>data</ogc:Literal>
                        </ogc:Function>
                        <ogc:Function name="parameter">
                            <ogc:Literal>smooth</ogc:Literal>
                            <ogc:Literal>true</ogc:Literal>
                        </ogc:Function>
                        <ogc:Function name="parameter">
                            <ogc:Literal>levels</ogc:Literal>
                            <ogc:Literal>-50</ogc:Literal>
                            <ogc:Literal>-45</ogc:Literal>
                            <ogc:Literal>-30</ogc:Literal>
                            <ogc:Literal>-25</ogc:Literal>
                            <ogc:Literal>-20</ogc:Literal>
                            <ogc:Literal>-15</ogc:Literal>
                            <ogc:Literal>-10</ogc:Literal>
                            <ogc:Literal>-5</ogc:Literal>
                            <ogc:Literal>0</ogc:Literal>
                            <ogc:Literal>5</ogc:Literal>
                            <ogc:Literal>10</ogc:Literal>
                            <ogc:Literal>15</ogc:Literal>
                            <ogc:Literal>20</ogc:Literal>
                            <ogc:Literal>25</ogc:Literal>
                            <ogc:Literal>30</ogc:Literal>
                            <ogc:Literal>35</ogc:Literal>
                            <ogc:Literal>40</ogc:Literal>
                            <ogc:Literal>45</ogc:Literal>
                            <ogc:Literal>50</ogc:Literal>
                            <ogc:Literal>60</ogc:Literal>
                            <ogc:Literal>70</ogc:Literal>
                            <ogc:Literal>80</ogc:Literal>
                            <ogc:Literal>90</ogc:Literal>
                            <ogc:Literal>100</ogc:Literal>
                        </ogc:Function>
                    </ogc:Function>


                </Transformation>

                <Rule>
                    <Name>rule1</Name>
                    <Title>Blue Line</Title>
                    <Abstract>A solid blue line with a 1 pixel width</Abstract>

                    <LineSymbolizer>
                        <Stroke>
                            <ogc:Function name="Interpolate">

                                <CssParameter name="stroke">#0000FF</CssParameter>
                                <CssParameter name="stroke-linejoin">round</CssParameter>
                                <CssParameter name="stroke-linecap">round</CssParameter>
                                <ogc:Literal>cosine</ogc:Literal>

                                <!-- Interpolation mode - defaults to linear -->
                            </ogc:Function>
                        </Stroke>
                    </LineSymbolizer>

                    <TextSymbolizer>
                        <Label>
                            <ogc:PropertyName>value</ogc:PropertyName>
                        </Label>

                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-style">Normal</CssParameter>
                            <CssParameter name="font-size">10</CssParameter>
                        </Font>

                        <LabelPlacement>
                            <LinePlacement></LinePlacement>
                        </LabelPlacement>
                        <Halo>
                            <Radius>
                                <ogc:Literal>2</ogc:Literal>
                            </Radius>
                            <Fill>
                                <CssParameter name="fill">#FFFFFF</CssParameter>
                                <CssParameter name="fill-opacity">0.85</CssParameter>
                            </Fill>
                        </Halo>

                        <Fill>
                            <CssParameter name="fill">#000000</CssParameter>
                        </Fill>

                        <VendorOption name="followLine">true</VendorOption>
                        <VendorOption name="repeat">200</VendorOption>
                        <VendorOption name="maxDisplacement">50</VendorOption>
                        <VendorOption name="maxAngleDelta">30</VendorOption>
                        <VendorOption name="group">no</VendorOption>

                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>
1
  • Interpolate doesn't work like that
    – Ian Turton
    Commented Sep 12, 2022 at 12:21

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.