Mapping: How to remove M and Z values from SHP files

When using Epi Info’s mapping features, you may encounter a situation where you receive a SHP file from an institution or colleague and when you try to open it in Epi Info’s mapping tool, you see this message:

Problem.jpg

To provide some background, ESRI’s Shapefiles (SHP) have different “shape types.” In the example above, someone has tried to open a SHP file of type 15. You can read more about them here (see page 4 in this link). ESRI has 14 different SHP types. Epi Info will only read five of those: 0, 1, 3, 5, and 8. The SHP types above 8 (i.e., 11, 13, 15, 18, 21, 23, 25, 28, 31) contain special attributes known as M (link) and Z (link) values. M values deal with linear referencing and Z values deal with elevation. Most SHP files do not have M and Z values, so encountering this situation should be rare.

You’re probably wondering if there’s a way to determine what shape type your SHP file is. Unless you have GIS software, there’s no easy way of determining SHP type. After the tutorial below, a method for visualizing SHP type will be presented.

Note: A SHP file uses several other files in order to provide the resultant maps with a rich feature set. One of these files is a *.prj file. This file provides the “projection” of the map (these are not always present, however). This file extension is the same as Epi Info’s main project type. So, to not confuse the two, it is always recommended to keep SHP files and their associated reference files in separate folders from the Epi Info project file that uses the map.

 

So, what can you do to fix the problem?

There are several options:

  • If possible, find a different map.  While obvious, if you downloaded a map from a website, see if it’s possible download a similar map with the same geographical area, but without route or elevation data.  If you got the map from a colleague, ask if they have a map without measurement (M) or elevation (Z) values.

  • If that’s not possible and you have access to ESRI’s ArcGIS software, you can remove the M and Z map attributes easily and save a new SHP file. After you have the new saved SHP file without M and Z data, you would use the new file in Epi Info.  See this link for instructions.

  • If you do not have ArcGIS and you cannot find a replacement SHP file (or KML file), you will have to download and install QGIS (link).  Once you have that setup, you will need to open your SHP file and remove the M and Z values from it and create a new SHP file.  Instructions on how to do this are as follows.  You can find some additional information on QGIS’s website here.

 Instructions on how to remove M or Z values from a SHP file using QGIS

After installing QGIS:

  1. Create a new project

    Step_1.jpg
  2. Now, add the SHP file as a layer

  3. Right-click on the newly opened layer

  4. Choose “Export,” then “Save Features As …”

  5. Un-check “Include z-dimension”

  6. Within the same dialogue box, un-check “Add saved file to map.” This is optional as we will not be saving this map project. The sole purpose is just to export a new file for Epi Info to consume.

  7. Within the same dialogue box, provide a filename (along with file path) in addition to choosing “ESRI Shapefile” as the format. It is highly recommended to create a new folder to store your exported file. This will keep it separated from your other SHP file.

     

Success!

If everything went well you will get a message from QGIS stating that the file has been exported successfully.  Now, all you have to do is open the newly created SHP file in Epi Info.

 

Determining SHP type

Now that you have QGIS installed, you can easily check SHP files for their type. If you go back to Step 3--right clicking on the SHP file layer, choose “Properties.” On the properties page, you can see the “Geometry” (aka SHP type) of your SHP file under “Information from provider.”