dataconverters icon indicating copy to clipboard operation
dataconverters copied to clipboard

KML -> Records (GeoJSON)

Open rufuspollock opened this issue 12 years ago • 7 comments

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

rufuspollock avatar Aug 07 '12 12:08 rufuspollock

QGIS can do that.

gka avatar Aug 07 '12 13:08 gka

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

napo avatar Aug 07 '12 13:08 napo

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.

nigelbabu avatar Jan 07 '13 04:01 nigelbabu

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.

rufuspollock avatar Jan 07 '13 09:01 rufuspollock

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 avatar Jan 07 '13 10:01 nigelbabu

@nigelbabu have you pushed all the code you have here or do you still have stuff on disk?

rufuspollock avatar Jan 19 '13 13:01 rufuspollock

@rgrp I have nothing on-disk. I'm hoping to talk to Adria and get some help to kick this code off my plate.

nigelbabu avatar Jan 21 '13 01:01 nigelbabu