I have 2 layers in the map file with different extents. In QGIS, I am able to see them one over the other in proper positions. However, when I am adding those 2 layers in the map file for MapServer (actually MS4W), only one of the 2 layers are visible depending upon whose extent is used in Map EXTENT.
Only that layer is visible whose extent (as shown in QGIS for that layer) is used in Map's EXTENT property.
When EXTENT=-7117600.0000000000000000 1367760.0000000000000000 4897040.0000000000000000 7809680.0000000000000000
When EXTENT=-164.1598054400749902 57.4191918763605997 -148.4810114236049969 70.7414186722972005
Following is the mapfile:
MAP
#EXTENT -164.1598054400749902 57.4191918763605997 -148.4810114236049969 70.7414186722972005
EXTENT -7117600.0000000000000000 1367760.0000000000000000 4897040.0000000000000000 7809680.0000000000000000
SIZE 3663 1964
IMAGECOLOR 255 255 255
SHAPEPATH "../data"
IMAGETYPE PNG
WEB
IMAGEPATH '/ms4w/tmp/ms_tmp/'
IMAGEURL '/ms_tmp/'
END
PROJECTION
"init=epsg:2964"
END
#
# Start of LAYER DEFINITIONS ---------------------------------------------
LAYER # Landcover raster layer begins here
NAME "landcover"
DATA "landcover-2.tif"
#EXTENT -7117600.0000000000000000 1367760.0000000000000000 4897040.0000000000000000 7809680.0000000000000000
STATUS OFF
TYPE RASTER
PROJECTION
"init=epsg:2964"
END
END # Landcover raster layer ends here
LAYER # Combined lakes layer begins here
NAME "combined-lakes"
DATA "combined-lakes.shp"
#EXTENT -164.1598054400749902 57.4191918763605997 -148.4810114236049969 70.7414186722972005
STATUS OFF
TYPE POLYGON
PROJECTION
"init=epsg:2964"
END
CLASS
NAME "lakes"
STYLE
COLOR 0 0 0
OUTLINECOLOR 32 32 32
END
END
END # Combined lakes layer ends here
# End of LAYER DEFINITIONS -------------------------------
END # end of map file
In QGIS, I am able to view both the layers properly:
What am I missing in my Map File that is causing this behavior?
Best Answer
It's not clear to me how you are calling those MS4W layers (by the way, thanks for using MS4W, hope it works well for your organization, I am the creator/maintainer/everything for it, ha). Please specify if you are using WMS, or CGI "mode=map&layers=all" request, or whatever.
Here are some notes:
you have STATUS OFF for your layers, I would have them as STATUS ON (see the demo mapfile included in
/ms4w/apps/local-demo/
). Test your mapfile with shp2img command asshp2img -m test.map -o ttt.png -all_debug 3
(for MS4W v5.0 / MapServer8 this command will be changed tomap2img
)use
gdalinfo
command for your raster layer, and aogrinfo
command for your vector (lakes) layer, to get the proper EXTENT values to put into those layers. (since you are using MS4W, execute firstsetenv.bat
before those commands)you have specified in your mapfile LAYER settings that both your layers are in the same source projection, please verify that both your data sources are in the EPSG:2964 projection. By your commented extent for the
combined-lakes
layer, it seems that its source projection is actually EPSG:4326 Please review the 'Important notes" section at https://mapserver.org/mapfile/projection.html Always think of the top MAP-level projection as the output projection, and then specify a PROJECTION object for each layer, using the source projection for each dataset. If you discover that thecombined-layers
layer is actually in the EPSG:4326 projection, then for that layer change the line "init=epsg:2964" to "init=epsg:4326", so MapServer knows that layer's source projection, so MapServer can then reproject it to your output projection on-the-fly.QGIS does have on-the-fly reprojection, which can be confusing as you might assume that all of your data shown there is in the same projection, even if they might not be
Finally, thanks so much for the positive feedback for MS4W. I have put now 20 years of effort into that product. Thanks again, and happy mapserv-ing :)
Thanks again for mapserv-ing!