Skip to main content
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

Release files for mappyfile-geojson 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for mappyfile-geojson 0.1.2
File Interpreter ABI Platform
mappyfile_geojson-0.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / mappyfile_geojson-0.1.2-py2.py3-none-any.whl

Download URL mappyfile_geojson-0.1.2-py2.py3-none-any.whl
Size 6.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3b8c51a8da30f894d88e387281445d1a10fe7765af7aef378ef5ea9337dd98e8
BLAKE2b-256 checksum
How to use checksums
d8398b3f3883e714819da41fd0cbb41d8e26ea01b844b16219473bfc6b875ee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0.0

2 release files

0.4.0

5 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

1 release file

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page