8000 GitHub - maplet/mappyfile-geojson: A mappyfile plugin to convert GeoJSON to inline features
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

maplet/mappyfile-geojson

 
 

Repository files navigation

mappyfile-geojson

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

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

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 along with an example.map.

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

Requirements

  • Python 2.7 or Python 3.x
  • mappyfile (the plugin can be used on its own but will create a dictionary object structured to use within mappyfile). Installing mapfile should be done seperately.

Installation

Note installing the mappyfile-geojson plugin will automatically install geoson.

pip install mappyfile
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

About

A mappyfile plugin to convert GeoJSON to inline features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
0