[GIS] Make “Nodata” transparent in raster – Mapfile/Mapserver

coordinate systemmapfilemapservernodatatransparency

I have a raster and I'm trying to make it display in Openlayers2, using Mapserver 7.0 in backend. My problem is, I think, that because the online map is not the same projection as my data, Mapserver (or something in between) reprojects the data and ugly black portions now surrounds the actual data like this (See here, but I'm not sure if it is accessible outside the campus) :

Black portions added to the data when displaying in another projection

What I want to do is simply remove those black areas, probably using some configuration in the mapfile.. I looked to some configurations such as :

PROCESSING "NODATA=-999"
CLASS 
    EXPRESSION ([pixel] = -999)
    STYLE
        COLOR "#FFFFFF00"           # transparent black (RGBA)
    END
END

I also tried putting this : "wcs_rangeset_nullvalue"

Or tried using the OFFSITE 0 0 0, but this made anything that was black in the map to become transparent..

So far, all I was able to do is either make the whole map disapear, make anything that is black be transparent, or no difference at all!

Data projection :
NAD_1983_CSRS_Northwest_Territories_Lambert
WKID : 3581 Autorité : EPSG
Projection: Lambert_Conformal_Conic

The map is in EPSG:4269.

MAP 
  NAME              "FRANKLIN"
  EXTENT            -180 -90 180 90
  INCLUDE           "../include/ec_map_default.map"
  WEB
   IMAGEPATH        "/data/ms_tmp/"     #chemin reel 
   IMAGEURL         "/ms_tmp/"              #alias dans apache qui pointe sur IMAGEPATH    
   METADATA
    "wms_name"                            "FRANKLIN"
    "wms_title"                           "FRANKLIN"
    "wms_abstract"                        "FRANKLIN"
    "wms_description"                     "FRANKLIN"
    "wms_keywordlist"                     ""
    "wms_onlineresource"                  "http://bul-geo-stock1.ulaval.ca/mapserv?map=franklin&service=WMS&"
    "wms_srs"                             "EPSG:3857 EPSG:2036 EPSG:2037 EPSG:2148 EPSG:2149 EPSG:2150 EPSG:3797 EPSG:4269 EPSG:4326 EPSG:26917 EPSG:26918 EPSG:26919 EPSG:26920 EPSG:32183 EPSG:32184 EPSG:32185 EPSG:32186 EPSG:32187 EPSG:32188 EPSG:32189 EPSG:32190 EPSG:32198 EPSG:42105 EPSG:42304 EPSG:900913"
    "wms_extent"                          "-180 -90 180 90"
    INCLUDE "../include/ec_web_metadata_getfeatureinfo.map"
  END
END
PROJECTION
 "init=epsg:4269"
END
LAYER
  NAME      "coppermine1823_york_factory"
  #OFFSITE     0 0 0 #255 255 255
  TYPE      RASTER
  #DATA    "../../../data1/matricielle/franklin/epsg3857/carte1.tif"
  DATA    "../../../data1/matricielle/franklin/carte1tif.tif"
  #DATA    "../../../data1/matricielle/franklin/contour_rouge/carte1tif1.tif"
  METADATA
    "wms_title"     "Route of the Expedition from York Factory to Cumberland House. and the Summer & Winter tracks from thence to Isle a La Crosse, in 1819 & 1820"
    "wms_abstract"  "Route of the Expedition from York Factory to Cumberland House. and the Summer & Winter tracks from thence to Isle a La Crosse, in 1819 & 1820"
  END
  PROJECTION
        "init=epsg:3581"
        #"init=epsg:3857"
  END
END

How can I achieve this?

Best Answer

You could use gdal to reproject the TIF file so that you are non re-projecting on the fly. This will have the added bonus of speeding up the rendering of your map.

It is also important that the "no data" pixels in the image are set to a value that is not one of the values required in the rest image (so black is a bad choice for "no data").

Related Question