[OpenLayers-Users] applying SLD to WMS raster

jdmorgan jdmorgan at unca.edu
Fri Oct 19 09:00:39 PDT 2012


Hello,

I am attempting to adjust the symbology of a loaded WMS raster layer 
(img file on server).It is the NLCD dataset.The WMS layer loads find with

nlcd = new OpenLayers.Layer.WMS(

'nlcd',

'http://server /fswms/html/rlayers',

{layers: 'nlcd-2006', transparent: true,

projection: new OpenLayers.Projection("EPSG:4326")

},

{

isBaseLayer: false

}

);

And I have a SLD file that I have created in which I am attempting to 
make all of the pixels with the value of 11 opacity of 0.

<?xml version="1.0" encoding="ISO-8859-1"?>

<StyledLayerDescriptor version="1.0.0"

xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"

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">

<NamedLayer>

<Name>nlcd</Name>

<UserStyle>

<Title>ncld test</Title>

<FeatureTypeStyle>

<Rule>

<RasterSymbolizer>

<ColorMap>

<ColorMapEntry opacity="0" color="#000000" quantity="11" />

</ColorMap>

</RasterSymbolizer>

</Rule>

</FeatureTypeStyle>

</UserStyle>

</NamedLayer>

</StyledLayerDescriptor>

The WML layer ends up being map.layers[3] in my test application so I 
attempting to apply the SLD by the following code but it is not working.

//this is in the init:

OpenLayers.Request.GET({

url: "sldcode.sld",

success: complete

});

//function that attempts to apply SLD

function complete(req) {

mySLD = format.read(req.responseXML || req.responseText);

map.layers[3].mergeNewParams({sld_body:mySLD});

}

Any help would be greatly appreciated.

Thanks,

Derek

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121019/7ee65e0a/attachment-0001.html>


More information about the Users mailing list