Skip to main content

A pure Python MapFile parser for working with MapServer

Project description

Version Docs Build Status Coveralls Appveyor Build Status Downloads

A pure Python parser for working with MapServer MapFiles, built using Lark. mappyfile is an official OSGeo Community Project.

mappyfile is used for formatting and validation in, and can be tested for free on any of your Mapfiles. If you find mappyfile useful please consider signing up for a professional account at This will help to fund maintenance and further development of both mappyfile and MapServer.


  • Python 3.8 or higher


mappyfile is available on PyPI (the Python Package Index), and can be installed using pip:

pip install mappyfile

This will also install its required dependencies - Lark, and jsonschema.

To install the optional lark-cython library for better performance on CPython you can run the following command:

pip install mappyfile[lark_cython]

mappyfile is also available on conda. Install as follows:

conda install -c conda-forge mappyfile


Full documentation is available at


From within Python scripts:

import mappyfile

mapfile ="./docs/examples/")

# update the map name
mapfile["name"] = "MyNewMap"

new_layer_string = """
    NAME 'land'
    DATA '../data/vector/naturalearth/ne_110m_land'
            COLOR 107 208 107
            OUTLINECOLOR 2 2 2
            WIDTH 1

layers = mapfile["layers"]

new_layer = mappyfile.loads(new_layer_string)

layers.insert(0, new_layer) # insert the new layer at any index in the Mapfile

for l in layers:
    print("{} {}".format(l["name"], l["type"]))

print(mappyfile.dumps(mapfile, indent=1, spacer="\t"))

Three command line tools are available - format, validate, and schema:

mappyfile format
mappyfile validate D:\ms-ogc-workshop\ms4w\apps\ms-ogc-workshop\**\*.map
mappyfile schema mapfile-schema-8-0.json --version=8.0



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mappyfile-1.0.0.tar.gz (107.4 kB view hashes)

Uploaded source

Built Distribution

mappyfile-1.0.0-py2.py3-none-any.whl (59.4 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page