The idea behind alpha-by-value maps is very simple (even if the paper runs to 11 pages) we just make a polygon more transparent in proportion to the population that is contained in it. Here is the same map as before but with the transparency adjusted in proportion to population (again click to explore it).
Now this is exactly the same data set as in the previous map but now our eye is drawn to California and Texas as they are more populous while Nebraska and friends have faded into the background (quite literally). Even Michigan is less obvious now.
If you look at the SLD below you can see there is one key difference between this file and the previous one. I am now calculating the opacity using a function.
Lines 39-44 (and in the other classes) divides the population of the state (the PERSONS attribute) by 30 million (just higher than California’s population) and then uses this value (between 0 and 1) as the opacity value when rendering the polygon.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | <?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 unemployment</Name>
<UserStyle>
<Name>unemployment</Name>
<Title>unemployment in the United States</Title>
<Abstract>A sample filter that filters the United States into three
categories of unemployment, drawn in different colors</Abstract>
<FeatureTypeStyle>
<Rule>
<Title>< 5%</Title>
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:Mul>
<ogc:Div>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
<ogc:Add>
<ogc:PropertyName>EMPLOYED</ogc:PropertyName>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
</ogc:Add>
</ogc:Div>
<ogc:Literal>100</ogc:Literal>
</ogc:Mul>
<ogc:Literal>5</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">
<ogc:Div>
<ogc:PropertyName>PERSONS</ogc:PropertyName>
<ogc:Literal>30e6</ogc:Literal>
</ogc:Div>
</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Title>5-7%</Title>
<ogc:Filter>
<ogc:PropertyIsBetween>
<ogc:Mul>
<ogc:Div>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
<ogc:Add>
<ogc:PropertyName>EMPLOYED</ogc:PropertyName>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
</ogc:Add>
</ogc:Div>
<ogc:Literal>100</ogc:Literal>
</ogc:Mul>
<ogc:LowerBoundary>
<ogc:Literal>5</ogc:Literal>
</ogc:LowerBoundary>
<ogc:UpperBoundary>
<ogc:Literal>7</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">
<ogc:Div>
<ogc:PropertyName>PERSONS</ogc:PropertyName>
<ogc:Literal>30e6</ogc:Literal>
</ogc:Div>
</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Title>> 7%</Title>
<!-- like a linesymbolizer but with a fill too -->
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:Mul>
<ogc:Div>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
<ogc:Add>
<ogc:PropertyName>EMPLOYED</ogc:PropertyName>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
</ogc:Add>
</ogc:Div>
<ogc:Literal>100</ogc:Literal>
</ogc:Mul>
<ogc:Literal>7</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">
<ogc:Div>
<ogc:PropertyName>PERSONS</ogc:PropertyName>
<ogc:Literal>30e6</ogc:Literal>
</ogc:Div>
</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Title>Boundary</Title>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke-width">0.2</CssParameter>
</Stroke>
</LineSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>STATE_ABBR</ogc:PropertyName><![CDATA[
]]><ogc:Function name="numberFormat">
<ogc:Literal>#.##</ogc:Literal>
<ogc:Mul>
<ogc:Div>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
<ogc:Add>
<ogc:PropertyName>EMPLOYED</ogc:PropertyName>
<ogc:PropertyName>UNEMPLOY</ogc:PropertyName>
</ogc:Add>
</ogc:Div>
<ogc:Literal>100</ogc:Literal>
</ogc:Mul>
</ogc:Function>
</Label>
<Font>
<CssParameter name="font-family">Times New Roman</CssParameter>
<CssParameter name="font-style">Normal</CssParameter>
<CssParameter name="font-size">14</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0.5</AnchorPointX>
<AnchorPointY>0.5</AnchorPointY>
</AnchorPoint>
</PointPlacement>
</LabelPlacement>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
|