Example 1.6: Defining Projections and Extents
Whoa! What happened here?
You've just experienced on-the-fly reprojection. When a PROJECTION object is defined in the mapfile, MapServer passes the layer and projection info to the Proj.4 library which does the reprojection. For more information about the Proj.4 library, please visit http://trac.osgeo.org/proj/ .
This example attempts to shed some light on the projection support in MapServer.
This is what the mapfile looks like (Example1-6.map):
The first thing you might have noticed with our mapfile is the original EXTENT has been commented out and the new EXTENT values don't look anything like latitude and longitude values. Also, we have added a PROJECTION object near the top and within each of our layers.
Let's have a look at the new object and parameter:
EXTENT 201621.496941 -294488.285333 1425518.020722
cs2cs +proj=latlong +datum=WGS84 +to +proj=laea +ellps=clrk66 +lat_0=45 +lon_0=-100
After typing the command, enter the southwestern coordinate pair
(the lower left coordinates), separated by a space:
208398.01 -372335.44 0.000
I then type the northeastern coordinate pair (upper right corner coordinates), again separated by space: -82.122902 49.38562 and the following values are returned:
1285308.08 632638.93 0.000
You will notice that "cs2cs" returns a set of three values. You can ignore the third value, 0.000, as it means to represent altitute (which we're not using). Anyway, we can not present the EXTENT as:
EXTENT 208398.01 -372335.44 1285308.08 632638.93
But it doesn't match up the extent above, you say. Well, that's what usually happens when you reproject--the map doesn't necessarily get centered as you'd expect. You can fudge around it, taking a few thousand meters off to the left and adding a few to the right. Or, you can use a graphical GIS package to give you the extent. Here are the instructions for getting EXTENT using ArcView.
MapServer can take projection definitions in two ways. The first is shown in the mapfile's output PROJECTION object (the first PROJECTION block). This is the traditional way of passing parameters to the Proj.4 library. The other way is to use the EPSG codes. These codes are standard projection codes (or spatial reference identifiers) as defined by the European Petroleum Survey Group (EPSG). In the case of our Lambert Azimuthal Equal-Area projection, it has a code of "2163". If you comment out the four lines after PROJECTION and uncomment the line "init=epsg:2163", this will provide the same information to Proj.4. If you want to learn more about EPSG codes, have a look at "/usr/local/share/proj/epsg" or "C:/proj/nad/epsg" ("/ms4w/proj/nad" in MS4W). Also, check out the EPSG web site at http://www.epsg.org .
If you need to learn more about projections, please look through some of the links below:
You can find more by searching the web for "map projection".