Display layers by attribute category

check the map

You can create such a map by using non-spatial attribute information in the data:

Map file

Below is the MapFile file(xmfa3.map):

01 MAP
02     IMAGETYPE "PNG"
03     EXTENT -180 -90 180 90
04     SIZE 600 300
05     SHAPEPATH "/gdata"
06     IMAGECOLOR 255 255 255
07     LAYER
08         NAME "states_poly"
09         DATA "wcountry.shp"
10         STATUS OFF
11         TYPE POLYGON
12         CLASSITEM "NAME"
13         CLASS
14             NAME "China"
15             EXPRESSION "CHINA"
16             STYLE
17                 COLOR 232 30 30
18             END
19         END
20         CLASS
21             NAME "Others"
22             STYLE
23                 COLOR 198 198 255
24             END
25         END
26     END
27     LAYER
28         NAME "states_line"
29         DATA "wcountry.shp"
30         STATUS OFF
31         TYPE LINE
32         CLASSITEM "NAME"
33         CLASS
34             NAME "China Boundary"
35             EXPRESSION "land"
36             STYLE
37                 COLOR 32 32 32
38                 WIDTH 1
39             END
40         END
41         CLASS
42             NAME "Others Boundary"
43             STYLE
44                 COLOR 150 150 150
45                 WIDTH 0.4
46             END
47         END
48     END
49 END

Mapfile for layer classification

The structure of the map file, through the object, looks like this

                                  MAP
      (states_poly) LAYER----------|---------LAYER (states_line)
                      | |
       (land) CLASS---|---CLASS (water) |-CLASS
                  | | |
            STYLE-| |-STYLE |-STYLE

The file changes are as follows:

7    LAYER7    LAYER
n8        NAME "world-country"n8        NAME "states_poly"
9        DATA "wcountry.shp"9        DATA "wcountry.shp"
11        TYPE POLYGON11        TYPE POLYGON
nn12        CLASSITEM "NAME"
12        CLASS13        CLASS
n13            NAME "States"n14            NAME "China"
15            EXPRESSION "CHINA"
14            STYLE16            STYLE
n15                COLOR 232 232 232n17                COLOR 232 330
18            END
19        END
20        CLASS
21            NAME "Others"
22            STYLE
23                COLOR 198 198 255
16            END24            END
19    LAYER27    LAYER
n20        NAME "country-line"n28        NAME "states_line"
21        DATA "wcountry.shp"29        DATA "wcountry.shp"
23        TYPE LINE31        TYPE LINE
nn32        CLASSITEM "NAME"
24        CLASS33        CLASS
n25            NAME "State Boundary"n34            NAME "China Boundary"
35            EXPRESSION "land"
26            STYLE36            STYLE
t27                COLOR 132 132 32t37                COLOR 32 32 32
38                WIDTH 1
39            END
40        END
41        CLASS
42            NAME "Others Boundary"
43            STYLE
44                COLOR 150 150 150
45                WIDTH 0.4
28            END46            END

Mapfile attribute description

MapFile still has only two layers, but the polygon layer is subdivided into two broad categories. Take a look at the extra parameters:

CLASSITEM "NAME"

This keyword is used to specify what properties are used by the separated class object. In this example, the property is NAME. If you open the Shapefile of the associated database file, you will see that there is a column (property) called `NAME.

The database records for Shapefile are stored in a DBF file. You can open a spreadsheet program, such as Openoffice.org's calculations, or on a desktop such as GIS software QGIS. If the data has metadata (should be), you can understand it through the contents of the metadata file. You can also use ogrinfo to display basic property information in Shapefile - Looking back at Example 1.1 (after the last few lines, "LayerSRS WKT:" shows the attribute name and type).

EXPRESSION "CHINA"

For each class, specify the attribute value to use. This is the simplest form of expression. Expressions can be more complex than this, allowing a regular comparison expression or logical expression.