[GIS] Retrieve single band from multiband raster served by Geoserver

geoservermulti-band

I have a Geoserver imagemosaic layer serving out a timeseries of 2band rasters with band names GRAY_BAND and Band2. When I query the layer both bands are returned I believe the map only shows Band2, but if I click on a point in geoservers openlayers previewer it shows values for both bands. Is there a way specify via a param which band is returned? My goal is to get the single band so I can apply an SLD color ramp to it.

I did see that you can use propertyName=GREY_BAND, which specifies the band in the GetFeatureInfo response, but even when specifying propertyName it seems like the SLD is applied to a composite of both bands.

Best Answer

From the GeoServer user manual:

<RasterSymbolizer>
    <Opacity>1.0</Opacity>
    <ChannelSelection>
            <GrayChannel>
                    <SourceChannelName>1</SourceChannelName>
            </GrayChannel>
    </ChannelSelection>
    <ColorMap extended="true">
            <ColorMapEntry color="#0000ff" quantity="3189.0"/>
            <ColorMapEntry color="#009933" quantity="6000.0"/>
            <ColorMapEntry color="#ff9900" quantity="9000.0" />
            <ColorMapEntry color="#ff0000" quantity="14265.0"/>
    </ColorMap>
</RasterSymbolizer>

http://docs.geoserver.org/stable/en/user/styling/sld/reference/rastersymbolizer.html#channelselection

Related Question