【geoserver】控制栅格服务的波段组合

【geoserver】控制栅格服务的波段组合

最近有朋友问我geoserver是否可以控制栅格数据的波段组合。我也没这么做过,好奇之下就到处搜了一通,终于在官网找到了解决方案。今天分享给大家。
geoserver可以通过sld样式的方式来控制栅格服务的波段组合,亲测可用。
下面是样式文件:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor 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" xsi:schemaLocation="http://www.opengis.net/sld
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd" version="1.0.0">
  <NamedLayer>
    <Name>test</Name>
    <UserStyle>
      <Title>A raster style</Title>
      <FeatureTypeStyle>
        <Rule>
          <RasterSymbolizer>
              <ChannelSelection>
                  <RedChannel>
                  <SourceChannelName>
                          <ogc:Function name="env">
                                  <ogc:Literal>B1</ogc:Literal>
                                  <ogc:Literal>3</ogc:Literal>
                          </ogc:Function>
                  </SourceChannelName>
                  </RedChannel>
                  <GreenChannel>
                  <SourceChannelName>
                          <ogc:Function name="env">
                                  <ogc:Literal>B2</ogc:Literal>
                                  <ogc:Literal>2</ogc:Literal>
                          </ogc:Function>
                  </SourceChannelName>
                  </GreenChannel>
                  <BlueChannel>
                  <SourceChannelName>
                          <ogc:Function name="env">
                                  <ogc:Literal>B3</ogc:Literal>
                                  <ogc:Literal>1</ogc:Literal>
                          </ogc:Function>
                  </SourceChannelName>
                  </BlueChannel>
              </ChannelSelection>
            </RasterSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

样式文件中<RedChannel>……</RedChannel>之间的便是红波段,也就是B1,如果想控制B1使用哪个波段,可以修改<ogc:Literal>3</ogc:Literal>中间的数字。其他波段同理。

此外,也可以在调用的时候追加env参数来控制使用的波段:
http://localhost:8083/geosolutions/wms?service=WMS&version=1.1.0&request=GetMap&layers=geosolutions:raster_multichannel&styles=&bbox=-180.0,-90.5,180.0,90.5&width=768&height=386&srs=EPSG:4326&format=application/openlayers&env=B1:4;B2:2;B3:3

真的是发现了宝库,官网中还有栅格sld的其它用法,如下:
geoserver官网

官网链接如下,进去后搜索<ChannelSelection>即可找到波段组合相关内容:https://docs.geoserver.org/stable/en/user/styling/sld/reference/rastersymbolizer.html

我现在还有个问题,如果有知道的大神欢迎回答一下。就是landsat系列数据都是一个tiff文件是一个波段,geoserver能不能把这些文件发成一个服务,然后控制波段组合?

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值