2

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?

4
  • 1
    Did you try "0" as NoData value? As this is the most common value for it, or is the raster-file set to -999?
    – Matte
    Commented Jun 2, 2016 at 15:18
  • Hi, thanks for the answer, where exactly would you recommand to try the NoData = "0" in the mapfile.. I didn't set anything particular in the raster per say, so everything should be default!
    – JSROY
    Commented Jun 3, 2016 at 14:01
  • PROCESSING directives would generally go in the LAYER, but that said I couldn't find any support for PROCESSING "NODATA=..." in the mapserver documentation.
    – nmtoken
    Commented Jul 28, 2020 at 12:35
  • OFFSITE 0 0 0 was the right thing to do but if you have black pixels also on the map area it will just not work as you hope. You can use some raster algebra and update the pixels inside the valid map are into for example 1 1 1. Or you can edit the source files and add alpha band. For that you will also need the valid map area as a polygon.
    – user30184
    Commented Sep 14, 2021 at 20:26

1 Answer 1

0

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

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.