Posts

Showing posts with the label osgeo

How to convert from kml to GeoJson with python3

To do it, you can import ogr from osgeo 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') But, if you try to run it, maybe you will see the following error: ImportError: No module named 'osgeo' This means that you need gdal libraries. If you try to install it with pip3 you will see the following: pip3 install gdal ... cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++     extensions/gdal_wrap.cpp:3168:22: fatal error: cpl_port.h: No such file or directory     compilation terminated.     error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 We search which pakage includes cpl_port.h: apt-file search cpl_por...