0

I'm trying to put inside an OpenLayers project the legend for an NDVI map. Previously I've created with QGIS 3.10 the SLD as indicated on the GeoServer's official documentation.

When I try to use GetLegendGraphic to see the legend's preview I see only the symbol of raster and not the legend. If I set the style as default for my raster layer I can use the link from GetLegendGraphic for see correcty my legend. But If I set "Associated" instead of "Dafault" I see again the raster's symbol.

Why I'm obligated to use "Default" for styling a raster?

EDIT

Here the WMS stylized(A) and here the WMS not stylized(B). The style name is NDVI.

https://gis.massimilianomoraca.it/geoserver/MassimilianoMoraca/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&LAYER=NDVI_Campania_20150807&SCALE=136494.42037699942

gives

For A

it is possible to see the legend and is not possible to do the same with

https://gis.massimilianomoraca.it/geoserver/MassimilianoMoraca/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&LAYER=NDVI_Campania_20160712&SCALE=136494.42037699942

for B.

The layer A has NDVI as default style and for B I've used "Associated".

2
  • can you add the actual URLs you are requesting and the results in each case
    – Ian Turton
    Commented Sep 1, 2020 at 14:12
  • I've do this now @IanTurton Commented Sep 1, 2020 at 14:39

1 Answer 1

0

You need to specify the name of the style you would like the the legend to use if you don't want to use the default one - in the same way as you must to make it appear in the map.

So https://gis.massimilianomoraca.it/geoserver/MassimilianoMoraca/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&LAYER=NDVI_Campania_20160712&SCALE=136494.42037699942&style=NDVI will return:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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