Skip to main content

A pure Python MapFile parser for working with MapServer

Project description

Version Docs Build Status Coveralls Downloads

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

https://raw.githubusercontent.com/geographika/mappyfile/master/docs/images/OSGeo_community_small.png

mappyfile is used for formatting and validation in https://app.mapserverstudio.net/, 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 https://mapserverstudio.net/. This will help to fund maintenance and further development of both mappyfile and MapServer.

Requirements

  • Python 3.8 or higher

Installation

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

Documentation

Full documentation is available at http://mappyfile.readthedocs.io/en/latest/

https://raw.githubusercontent.com/geographika/mappyfile/master/docs/images/class_parsed_small.png

Usage

From within Python scripts:

import mappyfile

mapfile = mappyfile.open("./docs/examples/raster.map")

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

new_layer_string = """
LAYER
    NAME 'land'
    TYPE POLYGON
    DATA '../data/vector/naturalearth/ne_110m_land'
    CLASS
        STYLE
            COLOR 107 208 107
            OUTLINECOLOR 2 2 2
            WIDTH 1
        END
    END
END
"""

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 raster.map formatted_raster.map
mappyfile validate D:\ms-ogc-workshop\ms4w\apps\ms-ogc-workshop\**\*.map
mappyfile schema mapfile-schema-8-0.json --version=8.0

Authors

Contributors

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.1.1.tar.gz (110.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mappyfile-1.1.1-py2.py3-none-any.whl (63.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mappyfile-1.1.1.tar.gz.

File metadata

  • Download URL: mappyfile-1.1.1.tar.gz
  • Upload date:
  • Size: 110.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mappyfile-1.1.1.tar.gz
Algorithm Hash digest
SHA256 1ffbf47ba61004a717e26587a1703c21cf3d6f4f14d2afb608d723ccc85db3e7
MD5 355b42e1f21bb9f33afb45779b4676ff
BLAKE2b-256 95fe92f9afc86338eab5dfb603fa93cc4840fc8e46e608ade9c2907beea0aea4

See more details on using hashes here.

File details

Details for the file mappyfile-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: mappyfile-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 63.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mappyfile-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c1c68db3e385f25e22d3ee11e77cc2f2fcccb870c9746c3bd1f066a1e8ca48cc
MD5 5a739be6c94658c15deb6beb8ff5060a
BLAKE2b-256 92ec05220e14cbc1601fe7ac078032b1fd58962cadf168fbea4f3fca6a5ab510

See more details on using hashes here.

Supported by

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