Saturday, 15 December 2018

python - Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'


I'm trying to import a dataset of UK postcode districts UK postcode districts from Google Fusion tables into geopandas with the aim of splicing it to a dataset of house prices.


The problem is that geopandas doesn't seem to like either the CSV/KML version of the data.


If I use the command geopandas.from_file(path) then I receive the error:


DriverError: unsupported driver: u'CSV'

I have the same error when I try to import a KML version of the data (You can download the data below).


I'm sure it's trivial, but can anyone work out what I'm doing wrong?


UK postcode districts - KML


UK postcode districts - CSV




Answer



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)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...