Updated RasterColorizer (markdown)

tmcw 2011-12-09 12:01:32 -08:00
parent a4d1973be8
commit fac1c58340

@ -81,36 +81,37 @@ In this example XML, the following value to color translation is performed:
* 18 <= x < 100 green blending to indigo * 18 <= x < 100 green blending to indigo
#!xml ```xml
<?xml version="1.0" encoding="utf-8"?> #!xml
<Map srs="+proj=latlong +datum=WGS84"> <?xml version="1.0" encoding="utf-8"?>
<Style name="elevation"> <Map srs="+proj=latlong +datum=WGS84">
<Rule> <Style name="elevation">
<RasterSymbolizer> <Rule>
<RasterColorizer default-mode="linear" default-color="white" epsilon="0.001"> <RasterSymbolizer>
<stop color="blue" value = "-1000" /> <RasterColorizer default-mode="linear" default-color="white" epsilon="0.001">
<stop color="red" value = "-500" mode = "discrete" /> <stop color="blue" value = "-1000" />
<stop color="yellow" value = "0" /> <stop color="red" value = "-500" mode = "discrete" />
<stop value = "5" /> <stop color="yellow" value = "0" />
<stop color="red" value = "10" /> <stop value = "5" />
<stop color="green" value = "15" /> <stop color="red" value = "10" />
<stop color="black" value = "17" mode = "exact" /> <stop color="green" value = "15" />
<stop color="indigo" value = "100" /> <stop color="black" value = "17" mode = "exact" />
</RasterColorizer> <stop color="indigo" value = "100" />
</RasterSymbolizer> </RasterColorizer>
</Rule> </RasterSymbolizer>
</Style> </Rule>
</Style>
<Layer name="dataraster">
<StyleName>elevation</StyleName> <Layer name="dataraster">
<Datasource> <StyleName>elevation</StyleName>
<Parameter name="file">../mapnik2/tests/data/raster/dataraster.tif</Parameter> <Datasource>
<Parameter name="type">gdal</Parameter> <Parameter name="file">../mapnik2/tests/data/raster/dataraster.tif</Parameter>
<Parameter name="band">1</Parameter> <Parameter name="type">gdal</Parameter>
</Datasource> <Parameter name="band">1</Parameter>
</Layer> </Datasource>
</Layer>
</Map> </Map>
```
# Python Bindings # Python Bindings
@ -140,13 +141,15 @@ This is the enumeration of the stop modes. The values are _mapnik2.COLORIZER_LIN
## Example Python ## Example Python
#!py ```python
import mapnik2 #!py
c = mapnik2.RasterColorizer( mapnik2.COLORIZER_DISCRETE , mapnik2.Color(0,0,0,255) ) import mapnik2
c.epsilon = 0.001 c = mapnik2.RasterColorizer( mapnik2.COLORIZER_DISCRETE , mapnik2.Color(0,0,0,255) )
c.add_stop(-10) c.epsilon = 0.001
c.add_stop(15.83, mapnik2.COLORIZER_EXACT) c.add_stop(-10)
c.add_stop(20, mapnik2.Color("red")) c.add_stop(15.83, mapnik2.COLORIZER_EXACT)
c.add_stop(30.25, mapnik2.COLORIZER_LINEAR, mapnik2.Color("green")) c.add_stop(20, mapnik2.Color("red"))
c.get_color(23.124) c.add_stop(30.25, mapnik2.COLORIZER_LINEAR, mapnik2.Color("green"))
c.stops[1].color c.get_color(23.124)
c.stops[1].color
```