opengeospatial / styles-and-symbology

OGC Styles & Symbology Standards
Other
11 stars 6 forks source link

Color functions to tune colored maps #31

Open ebocher opened 1 year ago

ebocher commented 1 year ago

Existing conformance classes required for this use case:

Example stylesheet:

SLD and SE introduces the Interpolate function that can be used to return a numeric value or a color. Geotools based on lesscss.org extends the color functions with nice operation as saturate, combine...

These types of functions are required to design advanced maps that play with colours. Below are two examples.

Example 1 Geotools SLD file

<?xml version="1.0" encoding="UTF-8"?>
<UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld"
           xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc">
    <Name>Default Styler</Name>
    <FeatureTypeStyle>
        <Rule>
            <PolygonSymbolizer>
                <Fill>
                    <CssParameter name="fill">
                        <ogc:Function name="Interpolate">
                            <ogc:PropertyName>POP</ogc:PropertyName>
                            <ogc:Literal>0</ogc:Literal>
                            <ogc:Literal>#cc0000</ogc:Literal>
                            <ogc:Literal>345</ogc:Literal>
                            <ogc:Literal>#3d85c6</ogc:Literal>
                            <ogc:Literal>color</ogc:Literal>
                        </ogc:Function>
                    </CssParameter>
                </Fill>
                <Stroke>
                    <CssParameter name="stroke">
                        <ogc:Literal>#ffffff</ogc:Literal>
                    </CssParameter>
                    <CssParameter name="stroke-width">
                        <ogc:Literal>1</ogc:Literal>
                    </CssParameter>
                </Stroke>
            </PolygonSymbolizer>
        </Rule>
</FeatureTypeStyle>
        </UserStyle>

Example 2 Geotools SLD file

<?xml version="1.0" encoding="UTF-8"?>
<UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld"
           xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc">
    <Name>Default Styler</Name>
    <FeatureTypeStyle>
        <Rule>
            <PolygonSymbolizer>
                <Fill>
                    <CssParameter name="fill">
                        <ogc:Function name="mix">
                            <ogc:Function name="Interpolate">
                            <ogc:PropertyName>IMPERVIOUS_FRACTION</ogc:PropertyName>
                            <ogc:Literal>0</ogc:Literal>
                            <ogc:Literal>#eeeeee</ogc:Literal>
                            <ogc:Literal>0.5</ogc:Literal>
                            <ogc:Literal>#ff71c1</ogc:Literal>
                                <ogc:Literal>1</ogc:Literal>
                                <ogc:Literal>#9855d9</ogc:Literal>
                            <ogc:Literal>color</ogc:Literal>
                            </ogc:Function>
                            <ogc:Function name="Interpolate">
                                <ogc:PropertyName>VEGETATION_FRACTION</ogc:PropertyName>
                                <ogc:Literal>0</ogc:Literal>
                                <ogc:Literal>#eeeeee</ogc:Literal>
                                <ogc:Literal>0.5</ogc:Literal>
                                <ogc:Literal>#8fce00</ogc:Literal>
                                <ogc:Literal>1</ogc:Literal>
                                <ogc:Literal>#38761d</ogc:Literal>
                                <ogc:Literal>color</ogc:Literal>
                            </ogc:Function>
                            <ogc:Literal>0.5</ogc:Literal>
                        </ogc:Function>
                    </CssParameter>
                </Fill>
                <Stroke>
                    <CssParameter name="stroke">
                        <ogc:Literal>#ffffff</ogc:Literal>
                    </CssParameter>
                    <CssParameter name="stroke-width">
                        <ogc:Literal>1</ogc:Literal>
                    </CssParameter>
                </Stroke>
            </PolygonSymbolizer>
        </Rule>
</FeatureTypeStyle>
        </UserStyle>

Describe any capability not already addressed by existing conformance classes:

Example image illustrating the portrayal use case:

Example 1

Color interpolation on single property (POP)

color_interpolate_rsu_lcz

Example 2

Composed color map with 2 properties (VEGETATION_FRACTION and IMPERVIOUS_FRACTION) See https://www.joshuastevens.net/cartography/make-a-bivariate-choropleth-map/ for more information

color_mix_interpolate_rsu_indicators

Data

Example 1 : https://github.com/orbisgis/POC-Carto/blob/main/data/rsu_lcz.geojson

Example 2 : https://github.com/orbisgis/POC-Carto/blob/main/data/rsu_indicators.geojson