【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的其它用法,如下:
官网链接如下,进去后搜索<ChannelSelection>
即可找到波段组合相关内容:https://docs.geoserver.org/stable/en/user/styling/sld/reference/rastersymbolizer.html
我现在还有个问题,如果有知道的大神欢迎回答一下。就是landsat系列数据都是一个tiff文件是一个波段,geoserver能不能把这些文件发成一个服务,然后控制波段组合?