In [12]:
import shapefile
import geopandas as gpd
In [84]:
shapefiles_cns_2016 = '/home/tono/Downloads/bseccenv10sh1f1_2002a2016_0/bseccenv10sh1f1_20160101_0/bseccenv10sh1f1_20160101_0.shp'
shapefiles_cns_2015 = '/home/tono/Downloads/bseccenv10sh1f1_2002a2016_0/bseccenv10sh1f1_20150101_0/bseccenv10sh1f1_20150101_0.shp'
data_censo2016 = gpd.read_file(shapefiles_cns)
In [77]:
d = {'080734': 'Cornella', '080771': 'Esplugues',
'081017': 'Hospitalet'}
cmun_tr = {'080734': '08073', '080771': '08077',
'081017': '08101'}
f_filter = lambda x: x in list(d.keys())
trio_geodata2016 = data_censo2016[data_censo2016['MUNICIPI'].apply(f_filter)]
trio_geodata2016.loc[:, 'CUSEC'] =\
(data_censo2016['MUNICIPI'].replace(cmun_tr) +
data_censo2016['DISTRICTE'] + data_censo2016['SECCIO'])
trio_geodata2016.reset_index(drop=True, inplace=True)
In [80]:
In [ ]:
In [83]:
trio_geodata2016.to_file('data/trio_llobregat_2016.geojson')
In [98]:
def get_trio_llobregat(filename):
data_censo = gpd.read_file(shapefiles_cns)
d = {'080734': 'Cornella', '080771': 'Esplugues',
'081017': 'Hospitalet'}
cmun_tr = {'080734': '08073', '080771': '08077',
'081017': '08101'}
f_filter = lambda x: x in list(d.keys())
trio_geodata = data_censo2016[data_censo['MUNICIPI'].apply(f_filter)]
trio_geodata.loc[:, 'CUSEC'] =\
(data_censo['MUNICIPI'].replace(cmun_tr) +
data_censo['DISTRICTE'] + data_censo['SECCIO'])
trio_geodata.reset_index(drop=True, inplace=True)
trio_geodata.to_crs(epsg=4326, inplace=True)
return trio_geodata
trio_geodata2015 = get_trio_llobregat(shapefiles_cns_2015)
trio_geodata2015.to_file('data/trio_llobregat_2015.geojson', driver='GeoJSON')
trio_geodata2016 = get_trio_llobregat(shapefiles_cns_2016)
trio_geodata2016.to_file('data/trio_llobregat_2016.geojson', driver='GeoJSON')
In [86]:
help(trio_geodata2015.to_file)
In [97]:
help(trio_geodata2015.to_crs)
In [ ]: