pythongeojsonmapservergml-geographic-markup-lan

Python GeoJson to GML conversion


I have a python application that creates polygons to identify geographic areas of interest at specific times. To this point I've been using geojson because of the handy geojson library that makes writing it easy. I put the time information in the file name. However now I need to publish my polygons via a WMS with TIME (probably going to use mapserver). As geojson doesn't appear to support a feature time and geojson-events hasn't been accepted yet, I thought I would try to convert to GML,however I cannot seem to locate a library that would make writing GML from python simple. Does one exist? I tried using the geojson-events format and then ogr2ogr to convert from geojson-events to gml but the time information gets dropped.

So looking for either:

a) an efficient way to write GML from python,

b) a way to encode datetime information into geojson such that ogr will recognize it or

c) another brilliant solution I haven't thought of.


Solution

  • To convert GeoJSON into GML you could use GDAL (Geospatial Data Abstraction Library). There are numerous ways of using the library including directly with Python

    However as you want to set up a WMS to serve your data, you might want to set up a spatial database, for example PostgreSQL/PostGIS, and import the GeoJSON directly into the database, then allow MapServer to do the conversion for you.

    See Store a GeoJSON FeatureCollection to postgres with postgis for details of how you might do this.