2

The map below is produced in ArcGIS software using the multiple attribute visualization tool (a map based on two attributes the color represents different zones based on the zone attribute value and the size of the points indicates the observation in that zone based on observation attribute value of the layer), but what i want is to do the same thing in SLD.

I read the SLDCookbook but i didn't see an example for two attributes.

My first question is the possibility of doing this in SLD?

My second question is how to do it?

My third question is is it possible to do the same visualization in QGIS?

A map based on two attributes the color represents different zones based on the zone attribute value and the size indicates the observation in that zone based on observation attribute value of the layer

2

You need to provide two (or more) Rules to the FeatureTypeStyle, they are drawn in the order they occur in the file so the first one is at the bottom of the map and the others overlaid in order.

enter image description here

So you could have the following SLD (which doesn't work exactly as I expected in QGis probably to the functions not being found) to colour the polygons, draw a proportional symbol in the centre of each polygon and finally to label them with the % unemployment rate:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 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" xmlns:gml="http://www.opengis.net/gml"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
    <NamedLayer>
        <Name>USA states population</Name>
        <UserStyle>
            <Name>population</Name>
            <Title>Population in the United States</Title>
            <Abstract>A sample filter that filters the United States into three
        categories of population, drawn in different colors</Abstract>
            <FeatureTypeStyle>
                <Rule>
                    <Title>&lt; 2M</Title>
                    <ogc:Filter>
                        <ogc:PropertyIsLessThan>
                            <ogc:PropertyName>PERSONS</ogc:PropertyName>
                            <ogc:Literal>2000000</ogc:Literal>
                        </ogc:PropertyIsLessThan>
                    </ogc:Filter>
                    <PolygonSymbolizer>
                        <Fill>
                            <!-- CssParameters allowed are fill (the color) and fill-opacity -->
                            <CssParameter name="fill">#4DFF4D</CssParameter>
                            <CssParameter name="fill-opacity">0.7</CssParameter>
                        </Fill>     
                    </PolygonSymbolizer>
                </Rule>
                <Rule>
                    <Title>2M - 4M</Title>
                    <ogc:Filter>
                        <ogc:PropertyIsBetween>
                            <ogc:PropertyName>PERSONS</ogc:PropertyName>
                            <ogc:LowerBoundary>
                                <ogc:Literal>2000000</ogc:Literal>
                            </ogc:LowerBoundary>
                            <ogc:UpperBoundary>
                                <ogc:Literal>4000000</ogc:Literal>
                            </ogc:UpperBoundary>
                        </ogc:PropertyIsBetween>
                    </ogc:Filter>
                    <PolygonSymbolizer>
                        <Fill>
                            <!-- CssParameters allowed are fill (the color) and fill-opacity -->
                            <CssParameter name="fill">#FF4D4D</CssParameter>
                            <CssParameter name="fill-opacity">0.7</CssParameter>
                        </Fill>     
                    </PolygonSymbolizer>
                </Rule>
                <Rule>
                    <Title>&gt; 4M</Title>
                    <!-- like a linesymbolizer but with a fill too -->
                    <ogc:Filter>
                        <ogc:PropertyIsGreaterThan>
                            <ogc:PropertyName>PERSONS</ogc:PropertyName>
                            <ogc:Literal>4000000</ogc:Literal>
                        </ogc:PropertyIsGreaterThan>
                    </ogc:Filter>
                    <PolygonSymbolizer>
                        <Fill>
                            <!-- CssParameters allowed are fill (the color) and fill-opacity -->
                            <CssParameter name="fill">#4D4DFF</CssParameter>
                            <CssParameter name="fill-opacity">0.7</CssParameter>
                        </Fill>     
                    </PolygonSymbolizer>
                </Rule>
                <Rule>
                    <Title>Unemployment</Title>
                    <PointSymbolizer>
                        <Geometry>
                            <ogc:Function name="centroid">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                            </ogc:Function>
                        </Geometry>
                        <Graphic>
                            <Mark>
                                <WellKnownName>circle</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#FF0000</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>
                                <ogc:Mul>
                                    <ogc:Div>
                                        <ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
                                        <ogc:PropertyName>PERSONS</ogc:PropertyName>
                                    </ogc:Div>
                                    <ogc:Literal>10</ogc:Literal>
                                </ogc:Mul>
                            </Size>
                        </Graphic>
                    </PointSymbolizer>

                </Rule>
                <Rule>
                    <Title>Boundary</Title>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke-width">0.2</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                    <TextSymbolizer> 
                        <!-- <Geometry>
                            <ogc:Function name="centroid">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                            </ogc:Function>
                        </Geometry> -->
                        <Label>
                            <ogc:Mul>
                                <ogc:Div>
                                    <ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
                                    <ogc:PropertyName>PERSONS</ogc:PropertyName>
                                </ogc:Div>
                                <ogc:Literal>100</ogc:Literal>
                            </ogc:Mul>
                        </Label>

                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.5</AnchorPointY>
                                </AnchorPoint>
                            </PointPlacement>
                        </LabelPlacement>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.