12.
Projection
Up one level
To set up projections you must define two projection objects: one for the output image (in the MAP object) and one for each layer (in the LAYER objects) to be projected. MapServer relies on the PROJ.4 library for projections. Projection objects therefore consist of a series of PROJ.4 keywords, which are either specified within the object directly or referred to in an epsg file. An epsg file is a lookup file containing projection parameters, and is part of the PROJ.4 library.
The following two examples both define the same projection (UTM zone 15, NAD83), but use 2 different methods:
Example1: Inline Projection Parameters
PROJECTION "proj=utm" "ellps=GRS80" "datum=NAD83" "zone=15" "units=m" "north" "no_defs" END
Example2: epsg Projection Use
PROJECTION "init=epsg:26915" END (this refers to an epsg lookup file that contains a '26915' code with the full projection parameters)
The next two examples both display how to possibly define unprojected lat/longs ("geographic"):
Example3: Inline Projection Parameters
PROJECTION "proj=latlong" "ellps=WGS84" "datum=WGS84" END
Example4: epsg Projection Use
PROJECTION "init=epsg:4326" END
Important Notes
- If all of your data in the mapfile is in the same projection, you DO NOT have to specify any projection objects. MapServer will assume that all of the data is in the same projection.
- If you specify a MAP-level projection, and then only one other LAYER projection object, MapServer will assume that all of the other layers are in the specified MAP-level projection.
- Always refer to the epsg file in lowercase, because it is a lowercase filename and on Linux/Unix systems this parameter is case sensitive.
For More Information
- If you get projection errors, refer to the MapServer Error page to check if your exact error has been discussed.
- Search the MapServer-users email list archives, odds are that someone has faced your exact issue before.
- See the PROJ.4 user guides for complete descriptions of supported projections and coordinate systems.
- Refer to the Cartographical Map Projections page for background information on projections.
raster image projection conversion
my question is why is my mapserver not showing a rectangular image map (raster data) in another given projection?
Details:
I installed the latest ms4w 5.0 (2.2.6 release from maptools.org)
and I have a NASA Blue Marble rectangular gif of the whole world and can see it perfectly when requesting EPSG:4326, however, I would like to be able to also see it in other projections. I tried the mollweide projection, which appears to be defined as 54009 in the proj/nad/epsg file. When I request EPSG:54009 I see a filled blue featureless rectangle. I am not sure what I am doing wrong, or what I may be missing.
According to the instructions on this page, the LAYER should specify the input projection, EPSG:4326 in this case, and the MAP should specify the output projection, EPSG:54009 in this case. My mapfile does just that, and I expected to see an elliptical-shaped mollweide projection of the rectangular NASA Blue Marble map yet only a blue rectangle shows up. Here is my request:
http://localhost/cgi-bin/mapserv.exe?map=/ms4w/mapfile.map&service=wms&version=1.1.1&request=getmap&layers=modis1&bbox=-180,-90,180,90&width=800&height=400&format=image/gif&styles=&srs=epsg:4326
notice that if epsg:4326 at the end is replaced with epsg:54009 to get the mollweide projection, then it doesn't appear to work - there is no error but there is only a blue rectangle, but the request as is with epsg:4326 gives the original rectangular map of the whole world from -180 to 180 longitude and from -90 to 90 latitude, same as looking directly at the gif in an image viewer.
Here is my mapfile:
MAP
NAME myserver
IMAGETYPE gif
SIZE 800 400
IMAGECOLOR 205 205 255
SHAPEPATH "/ms4w/data"
EXTENT -180 -90 180 90
# CONFIG "PROJ_LIB" "/ms4w/proj/nad/"
# CONFIG "GDAL_DATA" "/ms4w/gdaldata/"
WEB
IMAGEPATH "/ms4w/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
METADATA
"wms_title" "WMS Demo Server" ##REQUIRED - generates warning in xml output if missing
END
END
PROJECTION
"init=epsg:54009"
END
LAYER
NAME modis1
DATA modis1.gif
TYPE RASTER
STATUS OFF
# PROCESSING "LOAD_WHOLE_IMAGE=TRUE"
PROJECTION
"init=epsg:4326"
END
METADATA
"wms_title" "NASA Blue Marble"
"wms_srs" "EPSG:4326 EPSG:54009"
"wms_extent" "-180 -90 180 90"
END
END
END