#!/usr/bin/env python # coding: utf-8 # In[19]: get_ipython().run_line_magic('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]: get_ipython().system(' rm test.geojson') get_ipython().run_line_magic('time', "db.to_file('test.geojson', driver='GeoJSON')") # In[30]: get_ipython().run_cell_magic('time', '', "db['geometry'] = db['geometry'].apply(lambda x: x.wkb_hex)\ndb.to_feather('test.feather')\n") # ## De-serialise # In[32]: get_ipython().run_line_magic('time', "gjs = gpd.read_file('test.geojson', driver='GeoJSON')") gjs.plot(); # In[33]: get_ipython().run_line_magic('time', "gjs = gpd.read_file('test.shp')") gjs.plot(); # In[34]: from shapely.wkb import loads # In[40]: get_ipython().run_cell_magic('time', '', "ftr = pd.read_feather('test.feather')\nftr['geometry'] = ftr['geometry'].apply(lambda x: loads(x, hex=True))\nftr = gpd.GeoDataFrame(ftr)\n") # In[41]: ftr.plot();