1

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
2
  • I'm not familiar with MapServer but it seems like there has to be a way to project the GRIB to the same coordinate system that your shapefile uses. Do any of these help: unidata.ucar.edu/staff/edavis/notes/WCS/WCS-CRS-Issues.html
    – user15741
    May 16, 2014 at 14:14
  • i'll look into that, thanks. Also it seems that you can recalculate poisitions using something like "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +over +no_defs" not sure how to use it exactly
    – jorrebor
    May 16, 2014 at 14:39

3 Answers 3

1

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.

0

I had a similar problem using a grib file and the above solution aligned the data but the raster layer was still incomplete. My solution was to wrap the longitude by adding +lon_wrap=180to the projection string instead of +pm=-360

0

The accepted answer did not work for me (using version 4.05 of MS4W - that's Mapserver 7.7). However, after a lot of trial and error this projection block added to my layer did work:

PROJECTION
    "init=epsg:4326"
    "lon_wrap=180"
END

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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