Skip to main content

A mappyfile plugin to convert GeoJSON to inline Mapfile features

Project description

Version Build Status

A mappyfile plugin to convert GeoJSON to inline Mapfile features. Useful for adding dynamically created features (from web services, user created features), to a map.

import mappyfile
import mappyfile_geojson
# will soon be available to import as
# from mappyfile.plugins import geojson as mgeojson

gj = geojson.load(fn)
l = mappyfile_geojson.convert(gj)
print(mappyfile.dumps(l))

Converts:

{
  "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [ 102.0, 0.0 ],
      [ 103.0, 1.0 ],
      [ 104.0, 0.0 ],
      [ 105.0, 1.0 ]
    ]
  },
  "properties": {
    "prop0": "value0",
    "prop1": 0.0
  }
}

to:

LAYER
    EXTENT 102.0 0.0 105.0 1.0
    STATUS ON
    TYPE LINE
    PROCESSING "ITEMS=prop0,prop1"
    FEATURE
        ITEMS "value0;0.0"
        POINTS
            102.0 0.0
            103.0 1.0
            104.0 0.0
            105.0 1.0
        END
    END
END

Demo

An example of using the plugin with mappyfile can be found in example.py.

https://raw.githubusercontent.com/geographika/mappyfile-geojson/master/polygon.png

Requirements

  • Python 2.7 or Python 3.x

Installation

pip install mappyfile-geojson

Notes

  • Can calculate extent of input features, with optional buffer

  • Multipart features currently not implemented

  • Nested properties are not supported

    "properties": {
        "prop0": "value0",
        "prop1": { "this": "that" }
    }

    Will become:

    ITEMS "value0;{u'this': u'that'}"

Author

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-geojson-0.1.1.zip (8.0 kB view details)

Uploaded Source

Built Distribution

mappyfile_geojson-0.1.1-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mappyfile-geojson-0.1.1.zip.

File metadata

File hashes

Hashes for mappyfile-geojson-0.1.1.zip
Algorithm Hash digest
SHA256 b6436d0a72998c2d471e4f20dc5234c42c5ae3dfcf383551fdc11bfc76fa318e
MD5 314530e1797feb875a2e3fa2e6b7e8dc
BLAKE2b-256 e5d1f7bf0e7b48a08644cd4a552ca260bdaa28d0191f4b654f08808f401c0a90

See more details on using hashes here.

Provenance

File details

Details for the file mappyfile_geojson-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mappyfile_geojson-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a7cd5b07abe5ec0308149aac0c1c64e268c8db0c525da9d7b522a65356c2d866
MD5 da200934e62e593a6e6da7ab21a8ac1c
BLAKE2b-256 9fd35ee9434f7265797a93b6a2364d00de7b87710c028b684ad2164a5e0960e9

See more details on using hashes here.

Provenance

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