dataconverters
dataconverters copied to clipboard
KML -> Records (GeoJSON)
Suggest we just have a kml_parse method that yields iterator over geojson style python dicts.
Implementation
Various options here.
Note this is not supported by Fiona bindings for gdal (atm)
Other libraries:
- https://github.com/cleder/fastkml
- @sgillies keytree - github version https://github.com/rgrp/keytree
- gdal can do this (but no Fiona bindings) - but see https://github.com/Toblerity/Fiona/issues/23
QGIS can do that.
QGIS uses GDAL/OGR for this reason is very easy use the python interfaces to OGR/GDAL This is the command line
ogr2ogr -f "GeoJSON" file.geojson file.kml
I've written some code for the KML bits in a branch. Can someone give me a reality check on whether I'm headed in the right direction? I intend to add a Python Geo Interface if this is indeed the right direction.
Not sure why you need the Python Geo Interface - could you not just return geojson style python record objects (doing the python geo interface will require you creating proper "Record" objects which then implement that interface).
Regarding the code, as I'm not a KML expert, it is hard to tell whether this is right - could you add an example test (even a failing one) - that would at least tell me which kml file to look at it and an idea of what you expect output to be.
Implementing the Python Geo Interface has the advantage that if I do geojson.dumps()
, it will convert the object to geojson.
Well, I think the problem is, I'm not sure what the output should be. I already do have a test with prints out the current output. You can see if you run nosetests -d
@nigelbabu have you pushed all the code you have here or do you still have stuff on disk?
@rgrp I have nothing on-disk. I'm hoping to talk to Adria and get some help to kick this code off my plate.