1

I have a 32bit floating point raster containing only five values (-2, -1, 0, 1, 2 + -999000000 for noData don't ask me why, it was delivered to me), no compression, projected (EPSG:3857). I am using mapserver in combination with OpenLayers to display it in a web application as a tile layer. Everything seems ok and no errors are reported however this is what I get:

enter image description here

It looks like some tiles are not loaded (straight border of yellow colour in the upper middle) moreover there shouldn't be any transparent pixels over the land, water is noData. As I zoom in an d out as well as pan pixels and tiles seem to randomly appear and disappear.

Here is my basic mapfile I also tried different combinations of PROCESSING configurations but none of them work:

MAP
  NAME "qqqq"
  CONFIG "PROJ_LIB" "../../share/proj/"
  STATUS ON
  UNITS METERS
  WEB
    IMAGEPATH "/ms4w/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
    METADATA
      "wms_title"     "WMS qqqq"
      "wms_onlineresource" "http://xxx.xxx.xxx.xx/cgi-bin/mapserv.exe?"   ##required
      "wms_srs" "EPSG:4326 EPSG:3857"
      "wms_enable_request" "*"
      "WMS_FEATURE_INFO_MIME_TYPE" "application/json"
    END
  END

  PROJECTION
    "init=epsg:3857"
  END

  #
  # Start of layer definitions
  #

  LAYER
    NAME "products"
    PROCESSING "NODATA=-999000000"
    TEMPLATE "templates/NDVITemplateJSON.js"
    TOLERANCE 5
    TOLERANCEUNITS PIXELS
    METADATA
        "wms_title"    "WMS qqqq"   
    END
    VALIDATION
        "provider" "[a-z]+"
    END
    TYPE RASTER
    STATUS ON
    DATA '/xxx/xxx/xxx/%provider%/%spaceresolution%/%timeresolution%/%year%/%month%/%day%/%name%.tif'
    PROJECTION
      "init=epsg:3857"
    END
    PROCESSING "RESAMPLE=NEAREST"
    CLASSITEM "[pixel]"
    CLASS
      EXPRESSION ([pixel] = -2)
      STYLE
        COLOR 227 26 28
      END
    END
    CLASS
      EXPRESSION ([pixel] = -1)
      STYLE
        COLOR 231 245 54
      END
    END
    CLASS
      EXPRESSION ([pixel] = 0)
      STYLE
        COLOR 221 221 221
      END
    END
    CLASS
      EXPRESSION ([pixel] = 1)
      STYLE
        COLOR 0 245 0
      END
    END
    CLASS
      EXPRESSION ([pixel] = 2)
      STYLE
        COLOR 26 150 65
      END
    END
  END
END

I also tried to define colours based on ranges:

EXPRESSION ([pixel] >= 1 AND [pixel] < 2)
…

It didn't work.

Any ideas what might be wrong?

EDIT:

I found out the tif was produced by GrADS software

gdalinfo T2m-60_perc_2018_231.tif

…
Metadata:
  TIFFTAG_SOFTWARE=GrADS version 2.0.a7.1
  TIFFTAG_XRESOLUTION=0.018242123
  TIFFTAG_YRESOLUTION=0.02681388
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  AREA_OR_POINT=Area
…

And this might be the cause as I also found this question, unfortunately left unanswered.

3

Managed to solve this on my own. The problem was in the well known fact that a float is never an exact number. So 2 float is actually something like 2.9897689 or 2.000121101 and map server didn't like the fact that I wanted to display the map using whole number. Using:

EXPRESSION ([pixel] >= 1 AND [pixel] < 2)

partially addressed the issue but stull cut odd values just above 2. So I then used:

EXPRESSION ([pixel] >= 1.5 AND [pixel] < 2.5)

to capture all of the float values around 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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