TransWikia.com

Geoserver SLD file for a 4 channel GEOTIFF

Geographic Information Systems Asked by Iroh on April 19, 2021

I have a 4 channel(RGB+NIR) GeoTIFF(nodata=0) in uintformat. I use this image for WMS(base map) also use for WCS. I use below SLD style for RGB and it works fine(please check edit-2 ) but with RGB+NIR it comes blank space. Also, if I don’t use block that contains min and max pixel values, SLD style works fine but contrast is not good. Because of the storage issue, I want to use same image for both services. Thanks

Edit-1: WMTS layer(localhost:8080/geoserver/gwc/demo/layer1:sld?gridSet=EPSG:4326&format=image/png) for RGB image(3band), after zoom level 7, it comes blanks space again. With default raster SLD,everything seems fine.

Edit-2: After WMTS error, I’ve checked WMS for RGB image(3band) and there is same error. After zoom level 7 it gives blank page. When I click the blank screen I can get pixel value. With default raster SLD, everything seems fine.

<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
  <sld:UserLayer>
    <sld:LayerFeatureConstraints>
      <sld:FeatureTypeConstraint/>
    </sld:LayerFeatureConstraints>
    <sld:UserStyle>
      <sld:Title/>
      <sld:FeatureTypeStyle>
        <sld:Name>name</sld:Name>
        <sld:FeatureTypeName>Feature</sld:FeatureTypeName>
        <sld:Rule>
          <sld:MinScaleDenominator>75000</sld:MinScaleDenominator>
            <RasterSymbolizer>
            <Opacity>1.0</Opacity>
                <ChannelSelection>
                    <RedChannel>
                    <SourceChannelName>
                            <ogc:Function name="env">
                                    <ogc:Literal>B1</ogc:Literal>
                                    <ogc:Literal>1</ogc:Literal>
                            </ogc:Function>
                    </SourceChannelName>
                    <ContrastEnhancement>
                        <Normalize>
                          <VendorOption name="algorithm">ClipToMinimumMaximum</VendorOption>
                          <VendorOption name="minValue">10</VendorOption>
                          <VendorOption name="maxValue">1227</VendorOption>
                        </Normalize>
                  </ContrastEnhancement>
                    </RedChannel>
                    <GreenChannel>
                    <SourceChannelName>
                            <ogc:Function name="env">
                                    <ogc:Literal>B2</ogc:Literal>
                                    <ogc:Literal>2</ogc:Literal>
                            </ogc:Function>
                    </SourceChannelName>
                    <ContrastEnhancement>
                        <Normalize>
                          <VendorOption name="algorithm">ClipToMinimumMaximum</VendorOption>
                          <VendorOption name="minValue">10</VendorOption>
                          <VendorOption name="maxValue">1197</VendorOption>
                        </Normalize>
                    </ContrastEnhancement>
                    </GreenChannel>
                    <BlueChannel>
                    <SourceChannelName>
                            <ogc:Function name="env">
                                    <ogc:Literal>B3</ogc:Literal>
                                    <ogc:Literal>3</ogc:Literal>
                            </ogc:Function>
                    </SourceChannelName>
                    <ContrastEnhancement>
                        <Normalize>
                          <VendorOption name="algorithm">ClipToMinimumMaximum</VendorOption>
                          <VendorOption name="minValue">10</VendorOption>
                          <VendorOption name="maxValue">1162</VendorOption>
                        </Normalize>
                    </ContrastEnhancement>
                    </BlueChannel>
                    </ChannelSelection>
            </RasterSymbolizer>
   
        </sld:Rule>
        <sld:VendorOption name="composite">multiply</sld:VendorOption>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:UserLayer>
</sld:StyledLayerDescriptor>

One Answer

I solved the issue with new SLD which created from Qgis. I wanted use previous SLD for false colour represantation but after zoom level 7 SLD give blank space.

<SourceChannelName>
                            <ogc:Function name="env">
                                    <ogc:Literal>B3</ogc:Literal>
                                    <ogc:Literal>3</ogc:Literal>
                            </ogc:Function>
</SourceChannelName>

I think "SourceChannelName" blog give an error but I am not sure and I am new user of SLD so if I find the solution, I'll share.

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0" xmlns:sld="http://www.opengis.net/sld">
  <UserLayer>
    <sld:LayerFeatureConstraints>
      <sld:FeatureTypeConstraint/>
    </sld:LayerFeatureConstraints>
    <sld:UserStyle>
      <sld:Name>pansharp_0039_rgb</sld:Name>
      <sld:FeatureTypeStyle>
        <sld:Rule>
          <sld:RasterSymbolizer>
            <sld:ChannelSelection>
              <sld:RedChannel>
                <sld:SourceChannelName>1</sld:SourceChannelName>
                <sld:ContrastEnhancement>
                  <sld:Normalize>
                    <sld:VendorOption name="algorithm">StretchToMinimumMaximum</sld:VendorOption>
                    <sld:VendorOption name="minValue">0</sld:VendorOption>
                    <sld:VendorOption name="maxValue">1249</sld:VendorOption>
                  </sld:Normalize>
                </sld:ContrastEnhancement>
              </sld:RedChannel>
              <sld:GreenChannel>
                <sld:SourceChannelName>2</sld:SourceChannelName>
                <sld:ContrastEnhancement>
                  <sld:Normalize>
                    <sld:VendorOption name="algorithm">StretchToMinimumMaximum</sld:VendorOption>
                    <sld:VendorOption name="minValue">0</sld:VendorOption>
                    <sld:VendorOption name="maxValue">1149</sld:VendorOption>
                  </sld:Normalize>
                </sld:ContrastEnhancement>
              </sld:GreenChannel>
              <sld:BlueChannel>
                <sld:SourceChannelName>3</sld:SourceChannelName>
                <sld:ContrastEnhancement>
                  <sld:Normalize>
                    <sld:VendorOption name="algorithm">StretchToMinimumMaximum</sld:VendorOption>
                    <sld:VendorOption name="minValue">0</sld:VendorOption>
                    <sld:VendorOption name="maxValue">1100</sld:VendorOption>
                  </sld:Normalize>
                </sld:ContrastEnhancement>
              </sld:BlueChannel>
            </sld:ChannelSelection>
          </sld:RasterSymbolizer>
        </sld:Rule>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </UserLayer>
</StyledLayerDescriptor>

Correct answer by Iroh on April 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP