How can I create simple antialiased line features?
Up to table of contentsThe easiest way to produce antialiased lines is to:
- use a 24-bit output image type (IMAGEMODE RGB (or RGBA))
- set TRANSPARENCY ALPHA in the layer using antialiased lines
- set ANTIALIAS TRUE in the STYLE element of the CLASS with antialiased lines
The following mapfile snippets enable antialiased county borders:
...
IMAGETYPE png24
...
OUTPUTFORMAT
NAME png24
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END
...
LAYER
NAME counties
TYPE line
STATUS default
DATA "bdry_counln2"
TRANSPARENCY alpha
SYMBOLSCALE 5000000
CLASS
STYLE
WIDTH 3
COLOR 1 1 1
ANTIALIAS true
END
END
END
...
Note that the bdry_counln2 shapefile referenced in the counties layer is a line shapefile. A polygon shapefile could be substituted with roughly the same results, though owing to the nature of shapefiles each border would be rendered twice and the resulting output line would likely appear to be slightly thicker. Alternatively, one could use a polygon shapefile, set TYPE to POLYGON, and use OUTLINECOLOR in place of COLOR in the STYLE element.
Note that you can tweak the combination of STYLE->WIDTH and SYMBOLSCALE to modify line widths in your output images.
Apparently cartoline symbols can be used to achieve fancier effects.
This FAQ applies to: MapServer 4.8, MapServer 4.10