In [19]:
%matplotlib inline

import geopandas as gpd
import pandas as pd
import pysal as ps

Serialise and write

In [25]:
db = gpd.read_file(ps.examples.get_path('NAT.shp'))
db.plot();
In [29]:
! rm test.geojson
%time db.to_file('test.geojson', driver='GeoJSON')
rm: test.geojson: No such file or directory
CPU times: user 9.98 s, sys: 114 ms, total: 10.1 s
Wall time: 10.7 s
In [30]:
%%time
db['geometry'] = db['geometry'].apply(lambda x: x.wkb_hex)
db.to_feather('test.feather')
CPU times: user 408 ms, sys: 19.5 ms, total: 428 ms
Wall time: 430 ms

De-serialise

In [32]:
%time gjs = gpd.read_file('test.geojson', driver='GeoJSON')
gjs.plot();
CPU times: user 1.87 s, sys: 84.5 ms, total: 1.96 s
Wall time: 1.94 s
In [33]:
%time gjs = gpd.read_file('test.shp')
gjs.plot();
CPU times: user 602 ms, sys: 19 ms, total: 621 ms
Wall time: 618 ms
In [34]:
from shapely.wkb import loads
In [40]:
%%time
ftr = pd.read_feather('test.feather')
ftr['geometry'] = ftr['geometry'].apply(lambda x: loads(x, hex=True))
ftr = gpd.GeoDataFrame(ftr)
CPU times: user 244 ms, sys: 5.66 ms, total: 250 ms
Wall time: 249 ms
In [41]:
ftr.plot();