Opened 20 years ago

Closed 20 years ago

#855 closed defect (worksforme)

Legends don't work on rasters

Reported by: bartvde@… Owned by: sdlime
Priority: high Milestone:
Component: MapServer CGI Version: 4.2
Severity: normal Keywords:
Cc:

Description

I have a raster layer which operates through GDAL. The classification shows up 
in the map image, but the legend produces an empty image. I also tested this 
with legend.exe same result. The classification is on [pixel].

Added Frank to the cc as he might know something about this.

This is my MAP file:

MAP
  # NAME is the WMS root layer
  NAME "Basispakket"
  STATUS ON
  EXTENT 50000 400000 350000 650000
  SIZE 860 590 
  SHAPEPATH "D:/data/geopakhuis/"
  IMAGETYPE PNG
  IMAGECOLOR 255 255 255
  FONTSET "C:/ms4w/apps/chameleon/etc/fonts.txt"
  UNITS METERS
  WEB
    IMAGEPATH "/ms4w/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
    METADATA
      "WMS_TITLE"    "Basispakket WMS"
      "WMS_ABSTRACT"    "Basispakket WMS via UMN Mapserver"
      "WMS_ACCESSCONSTRAINTS"    "none"
      "WMS_SRS"    "EPSG:28992"
      "WFS_TITLE"    "Basispakket WFS via UMN Mapserver"
      "WFS_SRS"    "EPSG:28992"
      "OWS_SCHEMAS_LOCATION"    "http://schemas.opengis.net"
      "WFS_ONLINERESOURCE" "http://www.vz.geodan.nl:1111/cgi-bin/mapserv.exe?
map=/ms4w/apps/general/map/test.map&"
    END
  END

  PROJECTION
    "init=epsg:28992" 
  END

  LEGEND
    IMAGECOLOR 255 255 255
    KEYSIZE 18 12
    KEYSPACING 5 5
    LABEL
      SIZE 8
      TYPE truetype
      FONT sans
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
    END
    POSITION LL
    STATUS ON
  END

  OUTPUTFORMAT
    NAME "png"
    MIMETYPE "image/png"
    DRIVER "GD/PNG"
    EXTENSION "png"
    IMAGEMODE PC256
    TRANSPARENT FALSE
  END

 ##########################################
 # 4. Ahn_100                             #
 ##########################################
 LAYER
   METADATA
     "WMS_TITLE"    "Ahn 100"
     "WMS_ABSTRACT" "Ahn 100"
     "WMS_SRS"      "EPSG:28992"
     "WFS_TITLE"    "Ahn 100"
   END
   PROJECTION
     "init=epsg:28992" 
   END
   NAME "ahn_100"
   DATA "ahn_100\geogegevens\landsdekkend\ahn_100\w001001.adf"
   STATUS ON
   TYPE RASTER
   UNITS METERS
   CLASSITEM "[pixel]"
   CLASS
     EXPRESSION ([pixel] < 64)
     COLOR 0 0 0
   END
   CLASS
     EXPRESSION ([pixel] >= 64 AND [pixel] < 128)
     COLOR 255 0 0 
   END
   CLASS
     EXPRESSION ([pixel] >= 128 AND [pixel] < 196)
     COLOR 0 255 0 
   END
   CLASS
     EXPRESSION ([pixel] >= 196 AND [pixel] < 256)
     COLOR 0 0 255
   END
 END
END

Change History (2)

comment:1 by fwarmerdam, 20 years ago

Status: newassigned
Bart, 

My understanding is that your CLASS declarations have to include names for the
class to appear in the legend.  Could you change them and see if things work?

ie. 
   CLASS
     NAME "Less than 64"
     EXPRESSION ([pixel] < 64)
     COLOR 0 0 0
   END

comment:2 by bartvde@…, 20 years ago

Resolution: worksforme
Status: assignedclosed
Frank,

Sorry, this is such a stupid mistake, it works now. I copied the classes from 
your Raster howto tutorial and did not change them.

Bart
Note: See TracTickets for help on using tickets.