Adding an ESRI Shapefile layer

This example has the following assumptions:

  1. The shapefile comprises three standard files:
    • geology.shp
    • geology.dbf
    • geology.shx
  2. The shapefile is of geological features of the Sahara.
  3. It is Type Polygon.
  4. The shapefile has a field "REGION_NAME" that describes each polygon shape.
  5. The licensing agreement states a copyright message "Do not copy: it is ours" which must always be displayed when this layer is rendered.
  6. The system has been set up with one projection.

    A Projection is how the three dimensional surface of the earth is represented on a flat display. It involves distorting the 3D surface to make it 2D. There are many ways to do this, each used for different purposes (e.g. to maintain relative landmass areas or to make compass bearings straight lines on the map at the expense of distance distortion or to minimize distortion over one part of the map at the expense of others, to make it visually satisfying, etc.). By default we use a geographic projection that makes latitudes and longitudes appear as a rectilinear grid. This projection is the standard European Petroleum Survey Group projection EPSG:4326 and results in a familiar display of the world.

    Note: The System will handle many projections besides this one - it should handle most if not all projections handled by Proj4.
    Wikipedia has a detailed description of Shapefiles.

Steps:

  1. Place the files in a suitable location, e.g.:

    ~web/webservices/mapper/CLIENT/maps/layers/africa/sahara/geology/

    Note: Replace CLIENT with the back-end client name of your EMu implementation. For example, CLIENT would be replaced by am for the Australian Museum, nhm for the Natural History Museum, dpiq for Department of Primary Industry Queensland, etc.

  2. Create a new localized map file (if one has not already been created)

    -OR-

    Edit a previously created one. Look for a map file in:

    ~web/webservices/mapper/CLIENT/maps/config

    A map file is typically called standard.map; if multiple views or projections are enabled, there may be several map files in which case it may be necessary to add the layer to each projection as appropriate.

    In this example there is no client map file so we copy the default map file:

    ~web/webservices/mapper/maps/config/standard.map

    to the client location:

    ~web/webservices/mapper/CLIENT/maps/config/standard.map

  3. Edit the map file to add the new layer.

    In the map file the list of layers is in order of display priority, i.e. a layer will display above layers listed before it. Make a new entry in the map file:

    LAYER

	NAME "Saharan Geology"
	TYPE POLYGON
	STATUS OFF
	DATA "africa/sahara/geology/geology.dbf"
	CLASS
		NAME "geology"
		OUTLINECOLOR 0 127 0
		SYMBOL 0
		TEMPLATE "bogus.html"
	END
	METADATA
		"DescriptionField" "REGION_NAME"
		"Notes" "Do not copy: it is ours"
	END

END

Notes:

  1. The bogus.html entry is required if you want the Shapefile to participate in spatial queries (e.g. what geological region a specimen is in).
  2. It is necessary to specify the .dbf file of a Shapefile.

    Note: This differs from standard MapServer map file behaviour where it is possible to use geology rather than geology.dbf to specify the Shapefile.

  3. The DATA entry africa/sahara/geology/geology.dbf will first look for shapefiles stored in:

    ~web/webservices/mapper/CLIENT/maps/layers/africa/sahara/geology/

    and if they are not found, it will then look in the default data path:

    ~web/webservices/mapper/maps/layers/africa/sahara/geology/geology/

  4. The status value will be either OFF or ON.

    If OFF, the layer will not be turned on by default (e.g. when the map is first displayed) but must be selected by the user in order to be displayed.

  5. There are a number of other entries that can be used to change the behaviour of the layer (e.g. what scales the layer will be visible at, what colours different polygons within the layer show as, labelling etc.).

    See MapServer documentation for more in depth description of what can be done:

    http://mapserver.gis.umn.edu/docs/reference/mapfile/referencemanual-all-pages