4

Suppose you have a mapfile containing a background layer and a layer with a lot of overlapping linestrings.

Now, for the overlapping linestrings, it might be good to visualize their density, thus at places where a lot of lines do overlap they might be drawn more "solid" than at places where only a few lines are present.

Using QGIS, for example, I can do this by just turning the layer opacity to some small value (say five percent). In Mapserver, however, setting the opacity of the layer, the opacity will just make the whole layer see through, but will not add up for each single element.

How can I archive the desired effect?

2
  • Is the linestrings layer a POINT or a LINE kind of layer? If it's a POINT or it can be converted into a POINT layer then it might be worthwhile checking out the new CLUSTER feature: mapserver.org/mapfile/cluster.html#cluster
    – unicoletti
    Commented Oct 18, 2011 at 7:54
  • Thanks for the suggestion. However, the lines should remain as lines - this is set by the application.
    – Thilo
    Commented Oct 18, 2011 at 11:02

2 Answers 2

7

In Mapserver you can either set the OPACITY at the LAYER level or for each individual STYLE. A layer can have multiple styles for each of the different line types. This method relies on you being able to split your linestrings into different classes based on an attribute (such as year in the example below).

LAYER
CLASSITEM "year"
...
CLASS
  NAME "Lines"
  EXPRESSION "2010"
  STYLE
    OPACITY 70
    COLOR 178 114 1
    SIZE 15
  END # STYLE
END # CLASS
CLASS
  NAME "More Lines"
  EXPRESSION "2011"
  STYLE
    OPACITY 70
    COLOR 178 114 1
    SIZE 15
  END # STYLE
END # CLASS
END

If you just want one style, the solution is even simpler:

LAYER
...
CLASS
    NAME "Lines"
    STYLE
        OPACITY 5
        COLOR 178 114 1
        SIZE 15
    END # STYLE
END # CLASS
END
2
  • Thanks. While I have no attribute to cluster, your suggestion did the trick. You simply can use only one class without the expressions.
    – Thilo
    Commented Oct 18, 2011 at 11:05
  • I edited your answer to accomodate the simple solution.
    – Thilo
    Commented Oct 18, 2011 at 11:08
0

I'm not sure if MapServer implements this but SLD allows you to specify the opacity of the line itself in the styling. This is different than the layer transparency setting which as you say just makes the background see through.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.