Created
April 3, 2012 13:06
-
-
Save capooti/2291849 to your computer and use it in GitHub Desktop.
Parse a KML file and export it to GeoJSON with GDAL OGR Python bindings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import ogr | |
def kml2geojson(kml_file): | |
drv = ogr.GetDriverByName('KML') | |
kml_ds = drv.Open(kml_file) | |
for kml_lyr in kml_ds: | |
for feat in kml_lyr: | |
print feat.ExportToJson() | |
kml2geojson('/path/to/your.kml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment