Allow usage of expressions in SelectChannelName
- Contact: Andrea Aime
- Tracker: https://osgeo-org.atlassian.net/browse/GEOT-6035
- TLDR: When you have 13 bands, you don't prepare 286 RGB styles in advance
- Branch: https://github.com/geotools/geotools/tree/matrix
SLD allows to pick specific bands out of a raster, for rendering a false color map. Here is an example:
<RasterSymbolizer>
<ChannelSelection>
<RedChannel>
<SourceChannelName>2</SourceChannelName>
</RedChannel>
<GreenChannel>
<SourceChannelName>5</SourceChannelName>
</GreenChannel>
<BlueChannel>
<SourceChannelName>7</SourceChannelName>
</BlueChannel>
</ChannelSelection>
<RasterSymbolizer>
The schema for SourceChannelName
reports usage of a string, and the interfaces representing it are a match.
This was a suitable approach back when SLD 1.0 and SLD 1.1 were defined, but it's definitely showing its age with the current availability of multispectral imagery (e.g., Sentinel 2 has 13 bands) and hyperspectral imagery (drone mounted hyperspectral sensors have typically hundreds of bands). A way to pick the bands dynamically, without having to cast them in the SLD, is required.
This proposal aims at replacing String with Expression in SourceChannelName
, so that context free functions like env
can be used to indicate which bands are to be used in a particular rendering session.
<RasterSymbolizer>
<ChannelSelection>
<RedChannel>
<SourceChannelName>
<ogc:Function name="env">
<ogc:Literal>B1</ogc:Literal>
<ogc:Literal>2</ogc:Literal>
</ogc:Function>
</SourceChannelName>
</RedChannel>
<GreenChannel>
<SourceChannelName>
<ogc:Function name="env">
<ogc:Literal>B2</ogc:Literal>
<ogc:Literal>5</ogc:Literal>
</ogc:Function>
</SourceChannelName>
</GreenChannel>
<BlueChannel>
<SourceChannelName>
<ogc:Function name="env">
<ogc:Literal>B3</ogc:Literal>
<ogc:Literal>7</ogc:Literal>
</ogc:Function>
</SourceChannelName>
</BlueChannel>
</ChannelSelection>
<RasterSymbolizer>
We assume that the SourceChannelName
is seldomly used directly in client code, outside of building instances via factory/builders, so we propose a clean API break, while allowing the factories/builders to still work with fixed strings, along with expressions.
GeoTools 20.0, no backport planned
Choose one of:
- Under Discussion
- In Progress
- Completed
- Rejected,
- Deferred
Voting:
- Andrea Aime: +1
- Ben Caradoc-Davies: +1
- Ian Turton: +1
- Jody Garnett:
- Simone Giannecchini: +1
- Update API with a clean break
- Update SLD 1.0 parser and SLD 1.1 parser and the respective schemas used for validation
- Update rendering code to use expressions
- Update the StyleFactory and the style builder in gt-brewer to allow usage of Expression, while retaining the old method using String for backwards compatibility.
- Update the CSS parser to handle dynamic expression
- Make sure YSLD and MBStyle can at least compile and work as they used to (ideally, also work with expressions, if not too hard)
- Update documentation both in GeoTools and GeoServer
Before:
public interface SelectedChannelType {
...
public String getChannelName();
...
After:
public interface SelectedChannelType {
...
public Expression getChannelName();
...