[GIS] How wrap GRIB data in Mapserver 6.4

gribgrib-2mapserverraster

I'm trying to draw a combination of layers with Mapserver. One of the layer takes a shapefile as input and the other one is based on GRIB data.

The issue is that the GRIB layer (in green) is drawn from 0 deg to 360 deg. The shapelayers draws from -180 to 180. And indeed, when I examine the GRIB file in Panoply, the meta data of sample shows, among other things, this:

netcdf file:/D:/gribs/sample.grb {
  dimensions:
    lon = 360;
    lat = 181;
    isobaric = 4;
    time = 3;
  variables:
    float lat(lat=181);
      :units = "degrees_north";

    float lon(lon=360);
      :units = "degrees_east";

  ...
  other variables
  ...
  }

Which leads me to conclude that the coordinate system runs from 0 to 360 degrees in the east ward direction and from 0 to 180 in the north direction. So Mapserver is correct when it draws this image:

incorrect drawn grib layer

So my question is how can I wrap the GRIB image so that the right half is placed over the left half of the earth?

The url with parameters i use:

http://mapserver-dev.de.meteogroup.net/cgi-bin/mapserv?map=/var/www/mapserver/routeguard/poc_test.map&mode=map&layer=grib_sample&layer=world_outline_red

My mapfile:

    MAP
    EXTENT      -180 -90 360 90 #max x should be only 180, but then only half of the grib layer is drawn
    CONFIG      "CPL_DEBUG" "ON"
    CONFIG      "MS_ERRORFILE" "/var/www/mapserver/routeguard/poc.log"
    SYMBOLSET   "symbols.sym"
    FONTSET     "../fonts/fonts.txt"
    IMAGETYPE   PNG8
    IMAGECOLOR  255 255 255
    SIZE        1600 900

# ------------------------------------------------------------------------------
# the Map Projection
# ------------------------------------------------------------------------------
    PROJECTION
        #which to use????
        "init=epsg:4326" #54004 #4326
        "units=m"
    END

# ------------------------------------------------------------------------------
# the Web object
# ------------------------------------------------------------------------------

    WEB
        IMAGEURL    '/mapserver/routeguard/' #do not include the the var/www
        TEMPLATE    'poc_template.html'
    END

#--------------------------------------------------------------------------------
# the country mask
#--------------------------------------------------------------------------------
    #red world, defined in shp file
    LAYER
        NAME "world_outline_red"
        TYPE POLYGON
        DATA "/var/www/mapserver/data/routeguard/static/world_outline.shp"
        CLASS
            COLOR 255 0 0
        END

        PROJECTION
            "init=epsg:4326"
        END
    END

#----------------------------------------------------------------------------
#grib example
#----------------------------------------------------------------------------
    LAYER
        NAME "grib_sample"
        TYPE LINE
        CONNECTIONTYPE CONTOUR
        DATA "/var/www/mapserver/data/grib/routeguard/sample.grb"

        PROCESSING "BANDS=2"
        CLASS
            STYLE
                WIDTH 1
                COLOR 0 100 0
            END
        END

        PROJECTION
            "init=epsg:4326"
        END
        METADATA
            #"wms_srs"       "epsg:54004"
        END

    END


END #end map file

Best Answer

I solved this using a custom PROJECTION object in my mapfile:

    PROJECTION
        #"init=epsg:4326"
        "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +pm=-360"
    END

By setting the PM variable to -360 I was able to shift all data left.