Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

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

An online formatter demonstrating the libraries capabilities can be found at:

A presentation on mappyfile was given at FOSS4G Europe 2017 - slides are available for download here.


  • Python 2.7 or Python 3.x


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

pip install mappyfile

This will also install its required dependences Lark (lark-parser), and jsonschema.


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"))

Two command line tools are available - format and validate:

mappyfile format
mappyfile validate D:\ms-ogc-workshop\ms4w\apps\ms-ogc-workshop\**\*.map



Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
mappyfile-0.7.6-py2.py3-none-any.whl (45.7 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Oct 12, 2018
mappyfile-0.7.6.tar.gz (83.7 kB) Copy SHA256 hash SHA256 Source None Oct 12, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page