Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'
in case of csv, it probably would be easier to read it with pandas and then convert it to geopandas Dataframe
import pandas as pd import geopandas as gp from shapely.geometry import Point stations = pd.read_csv('../data/stations.csv') stations['geometry'] = stations.apply(lambda z: Point(z.X, z.Y), axis=1) stations = gp.GeoDataFrame(stations)
The KML driver isn't enabled by default as detailed in this github issue https://github.com/Toblerity/Fiona/issues/97. Basically, the KML driver doesn't seem to meet Fiona's quality requirements (as of 2014), not sure if it will be fixed in the future.
You could try to read a simple/standard-enough KML as follows:
import geopandas as gpd fiona.drvsupport.supported_drivers['kml'] = 'rw' # enable KML support which is disabled by default fiona.drvsupport.supported_drivers['KML'] = 'rw' # enable KML support which is disabled by default gpd.read_file("/path/to/your/test.kml")
I've tried to read a file here and it gave me the following output:
Credits to this gist:
Edit 20191021: With newer versions of
fiona, you might need to use
libkml instead of
fiona.drvsupport.supported_drivers['libkml'] = 'rw' # enable KML support which is disabled by default fiona.drvsupport.supported_drivers['LIBKML'] = 'rw' # enable KML support which is disabled by default
GeoPandas relies on the Fiona library (http://github.com/toblerity/Fiona) for the
from_file() implementation. At this time Fiona, and therefore GeoPandas, does not support CSV or KML input. If you can convert them to GeoJSON or Shapefiles, then GeoPandas should be able to read without a problem.