import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt
# set path to shapefiles
path = ('C:/Users/jtrum/world_bank/luanda_angola/')
# read shapefiles
angola0 = gpd.read_file(path + 'gadm41_AGO_0.shp')
angola1 = gpd.read_file(path + 'gadm41_AGO_1.shp')
angola2 = gpd.read_file(path + 'gadm41_AGO_2.shp')
angola3 = gpd.read_file(path + 'gadm41_AGO_3.shp')
# plot shapefiles as a 2 by 2 grid
fig, ax = plt.subplots(2, 2, figsize=(10, 10))
angola0.plot(ax=ax[0, 0], color='white', edgecolor='black')
angola1.plot(ax=ax[0, 1], color='orange', edgecolor='black')
angola2.plot(ax=ax[1, 0], color='green', edgecolor='black')
angola3.plot(ax=ax[1, 1], color='teal', edgecolor='black')
plt.show()
angola0
GID_0 | COUNTRY | geometry | |
---|---|---|---|
0 | AGO | Angola | MULTIPOLYGON (((19.89892 -17.87674, 19.89082 -... |
angola1
GID_0 | COUNTRY | GID_1 | NAME_1 | VARNAME_1 | NL_NAME_1 | TYPE_1 | ENGTYPE_1 | CC_1 | HASC_1 | ISO_1 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | AGO | Angola | AGO.1_1 | Bengo | NA | NA | Província | Province | 1 | AO.BO | AO-BGO | POLYGON ((14.22943 -9.63766, 14.23998 -9.63460... |
1 | AGO | Angola | AGO.2_1 | Benguela | Benguella | NA | Província | Province | 2 | AO.BG | AO-BGU | POLYGON ((14.48104 -13.63776, 14.48518 -13.659... |
2 | AGO | Angola | AGO.3_1 | Bié | NA | NA | Província | Province | 3 | AO.BI | NA | POLYGON ((17.50413 -11.69639, 17.51439 -11.699... |
3 | AGO | Angola | AGO.4_1 | Cabinda | NA | NA | Província | Province | 4 | AO.CB | AO-CAB | MULTIPOLYGON (((12.51154 -5.66378, 12.51563 -5... |
4 | AGO | Angola | AGO.5_1 | Cuando Cubango | NA | NA | Província | Province | 5 | AO.CC | AO-CCU | POLYGON ((21.11720 -17.93859, 21.10740 -17.949... |
5 | AGO | Angola | AGO.6_1 | Cuanza Norte | Cuanza-Nord|Kwanza Norte | NA | Província | Province | 6 | AO.CN | NA | POLYGON ((14.43879 -9.70253, 14.42907 -9.69892... |
6 | AGO | Angola | AGO.7_1 | Cuanza Sul | Cuanza-Sud|Kwanza Sul | NA | Província | Province | 7 | AO.CS | NA | POLYGON ((14.42245 -11.84332, 14.39943 -11.858... |
7 | AGO | Angola | AGO.8_1 | Cunene | NA | NA | Província | Province | 8 | AO.CU | AO-CNN | POLYGON ((14.90854 -17.38994, 14.82517 -17.390... |
8 | AGO | Angola | AGO.9_1 | Huambo | NA | NA | Província | Province | 9 | AO.HM | AO-HUA | POLYGON ((15.46121 -13.63435, 15.43790 -13.636... |
9 | AGO | Angola | AGO.10_1 | Huíla | NA | NA | Província | Province | 10 | AO.HL | NA | POLYGON ((13.86289 -16.19113, 13.84340 -16.212... |
10 | AGO | Angola | AGO.11_1 | Luanda | Loanda | NA | Província | Province | 11 | AO.LU | AO-LUA | MULTIPOLYGON (((13.25572 -9.18511, 13.25016 -9... |
11 | AGO | Angola | AGO.12_1 | Lunda Norte | NA | NA | Província | Province | 12 | AO.LN | NA | POLYGON ((18.49151 -10.42492, 18.49983 -10.430... |
12 | AGO | Angola | AGO.13_1 | Lunda Sul | NA | NA | Província | Province | 13 | AO.LS | NA | POLYGON ((19.98410 -11.26673, 19.97494 -11.261... |
13 | AGO | Angola | AGO.14_1 | Malanje | Malange | NA | Província | Province | 14 | AO.ML | NA | POLYGON ((17.56128 -11.70888, 17.55240 -11.704... |
14 | AGO | Angola | AGO.15_1 | Moxico | NA | NA | Província | Province | 15 | AO.MX | AO-MOX | POLYGON ((21.50316 -15.57387, 21.49482 -15.567... |
15 | AGO | Angola | AGO.16_1 | Namibe | Moçâmedes|Mossamedes | NA | Província | Province | 16 | AO.NA | AO-NAM | MULTIPOLYGON (((11.89305 -17.21833, 11.88961 -... |
16 | AGO | Angola | AGO.17_1 | Uíge | NA | NA | Província | Province | 17 | AO.UI | NA | POLYGON ((14.65188 -8.20525, 14.66517 -8.17885... |
17 | AGO | Angola | AGO.18_1 | Zaire | NA | NA | Província | Province | 18 | AO.ZA | AO-ZAI | POLYGON ((13.30162 -7.73082, 13.29917 -7.74248... |
angola2
GID_0 | COUNTRY | GID_1 | NAME_1 | NL_NAME_1 | GID_2 | NAME_2 | VARNAME_2 | NL_NAME_2 | TYPE_2 | ENGTYPE_2 | CC_2 | HASC_2 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.1_1 | Ambriz | NA | NA | Município | Municpality|City Council | 0104 | AO.BO.AM | POLYGON ((13.58780 -8.07294, 13.59133 -8.09631... |
1 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.2_1 | Dande | NA | NA | Município | Municpality|City Council | 0101 | AO.BO.DA | POLYGON ((14.00521 -8.29725, 14.02821 -8.29198... |
2 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.3_1 | Icolo e Bengo | NA | NA | Município | Municpality|City Council | 0102 | AO.BO.IB | POLYGON ((13.89476 -8.93760, 13.91837 -8.93758... |
3 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.4_1 | Muxima | Kissama | NA | Município | Municpality|City Council | 0103 | AO.BO.MU | POLYGON ((14.22943 -9.63766, 14.23998 -9.63460... |
4 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.5_1 | Nambuangongo | NA | NA | Município | Municpality|City Council | 0105 | AO.BO.NA | POLYGON ((14.71721 -8.04683, 14.71861 -8.06823... |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
158 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.2_1 | M'Banza Congo | Mbanza Kongo|M'Banza Kongo | NA | Município | Municpality|City Council | 1801 | AO.ZA.MK | POLYGON ((14.24712 -6.80609, 14.24132 -6.81415... |
159 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.3_1 | N'Zeto | Nzeto | NA | Município | Municpality|City Council | 1803 | AO.ZA.NZ | POLYGON ((13.31320 -7.71549, 13.30602 -7.72191... |
160 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.4_1 | Noqui | NA | NA | Município | Municpality|City Council | 1805 | AO.ZA.NO | POLYGON ((13.89886 -6.24828, 13.89953 -6.27159... |
161 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.5_1 | Soyo | NA | NA | Município | Municpality|City Council | 1802 | AO.ZA.SO | POLYGON ((12.98212 -6.39089, 12.96235 -6.41146... |
162 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.6_1 | Tomboco | NA | NA | Município | Municpality|City Council | 1804 | AO.ZA.TO | POLYGON ((13.00820 -7.02149, 12.98496 -7.01922... |
163 rows × 14 columns
angola3
GID_0 | COUNTRY | GID_1 | NAME_1 | NL_NAME_1 | GID_2 | NAME_2 | NL_NAME_2 | GID_3 | NAME_3 | VARNAME_3 | NL_NAME_3 | TYPE_3 | ENGTYPE_3 | CC_3 | HASC_3 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.1_1 | Ambriz | NA | AGO.1.1.1_1 | Ambriz | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.60011 -7.95300, 13.58338 -7.95193... |
1 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.1_1 | Ambriz | NA | AGO.1.1.2_1 | Bela Vista | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.60011 -7.95300, 13.59819 -7.94239... |
2 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.1_1 | Ambriz | NA | AGO.1.1.3_1 | Tabi | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.18305 -8.00315, 13.19910 -7.99620... |
3 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.2_1 | Dande | NA | AGO.1.2.1_1 | Barra do Dande | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.36503 -8.32537, 13.37787 -8.31847... |
4 | AGO | Angola | AGO.1_1 | Bengo | NA | AGO.1.2_1 | Dande | NA | AGO.1.2.2_1 | Caxito | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.52357 -8.65088, 13.54970 -8.65661... |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
522 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.5_1 | Soyo | NA | AGO.18.5.4_1 | Sumba | NA | NA | Commune | Commune | NA | NA | POLYGON ((12.83246 -6.21133, 12.82631 -6.21039... |
523 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.6_1 | Tomboco | NA | AGO.18.6.1_1 | Kingombe | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.34241 -6.31110, 13.36145 -6.33234... |
524 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.6_1 | Tomboco | NA | AGO.18.6.2_1 | Kinzau | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.05370 -7.04304, 13.03066 -7.03125... |
525 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.6_1 | Tomboco | NA | AGO.18.6.3_1 | Quiximba | NA | NA | Commune | Commune | NA | NA | POLYGON ((14.09292 -6.87123, 14.06199 -6.88029... |
526 | AGO | Angola | AGO.18_1 | Zaire | NA | AGO.18.6_1 | Tomboco | NA | AGO.18.6.4_1 | Tomboco | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.40281 -6.91802, 13.39253 -6.92343... |
527 rows × 17 columns
# extract Luanda, Angola from luanda1
luanda1 = angola1[angola1['NAME_1'] == 'Luanda']
luanda1
GID_0 | COUNTRY | GID_1 | NAME_1 | VARNAME_1 | NL_NAME_1 | TYPE_1 | ENGTYPE_1 | CC_1 | HASC_1 | ISO_1 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
10 | AGO | Angola | AGO.11_1 | Luanda | Loanda | NA | Província | Province | 11 | AO.LU | AO-LUA | MULTIPOLYGON (((13.25572 -9.18511, 13.25016 -9... |
# extract Luanda, Angola from luanda2
luanda2 = angola2[angola2['NAME_1'] == 'Luanda']
luanda2
GID_0 | COUNTRY | GID_1 | NAME_1 | NL_NAME_1 | GID_2 | NAME_2 | VARNAME_2 | NL_NAME_2 | TYPE_2 | ENGTYPE_2 | CC_2 | HASC_2 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
91 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.1_1 | Cacuaco | NA | NA | Município | Municpality|City Council | 1108 | AO.LU.CC | POLYGON ((13.33555 -8.84680, 13.32807 -8.84816... |
92 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.2_1 | Cazenga | NA | NA | Município | Municpality|City Council | 1105 | AO.LU.CZ | POLYGON ((13.31915 -8.83688, 13.32149 -8.84161... |
93 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.3_1 | Ingombota | NA | NA | Município | Municpality|City Council | 1101 | AO.LU.IN | POLYGON ((13.24521 -8.82360, 13.24350 -8.82758... |
94 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.4_1 | Kilamba Kiaxi | Kilamba Kiaxi | NA | Município | Municpality|City Council | 1106 | AO.LU.KK | POLYGON ((13.27703 -8.84495, 13.28397 -8.84877... |
95 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.5_1 | Maianga | NA | NA | Município | Municpality|City Council | 1102 | AO.LU.MA | POLYGON ((13.24222 -8.85261, 13.23758 -8.85664... |
96 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.6_1 | Rangel | NA | NA | Município | Municpality|City Council | 1103 | AO.LU.RA | POLYGON ((13.27703 -8.84495, 13.27180 -8.84202... |
97 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.7_1 | Samba | NA | NA | Município | Municpality|City Council | 1107 | AO.LU.SA | MULTIPOLYGON (((13.00907 -9.11587, 13.00547 -9... |
98 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.8_1 | Sambizanga | NA | NA | Município | Municpality|City Council | 1104 | AO.LU.SZ | POLYGON ((13.27602 -8.80478, 13.27317 -8.81079... |
99 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.9_1 | Viana | NA | NA | Município | Municpality|City Council | 1109 | AO.LU.VI | POLYGON ((13.28976 -9.17134, 13.28341 -9.17835... |
# extract Luanda, Angola from luanda3
luanda3 = angola3[angola3['NAME_1'] == 'Luanda']
luanda3
GID_0 | COUNTRY | GID_1 | NAME_1 | NL_NAME_1 | GID_2 | NAME_2 | NL_NAME_2 | GID_3 | NAME_3 | VARNAME_3 | NL_NAME_3 | TYPE_3 | ENGTYPE_3 | CC_3 | HASC_3 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
297 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.1_1 | Cacuaco | NA | AGO.11.1.1_1 | Cacuaco | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.36162 -8.83568, 13.36256 -8.82855... |
298 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.1_1 | Cacuaco | NA | AGO.11.1.2_1 | Funda | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.41151 -8.63637, 13.44697 -8.65711... |
299 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.1_1 | Cacuaco | NA | AGO.11.1.3_1 | Kikolo | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.35092 -8.77114, 13.35149 -8.77703... |
300 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.2_1 | Cazenga | NA | AGO.11.2.1_1 | Cazenga | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.31935 -8.83123, 13.31915 -8.83688... |
301 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.2_1 | Cazenga | NA | AGO.11.2.2_1 | Hoji Ya Henda | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.31115 -8.79006, 13.31111 -8.79574... |
302 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.2_1 | Cazenga | NA | AGO.11.2.3_1 | Tala Hadi | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.31701 -8.80510, 13.31901 -8.80969... |
303 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.3_1 | Ingombota | NA | AGO.11.3.1_1 | Ilha do Cabo | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.25614 -8.80953, 13.25545 -8.81734... |
304 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.3_1 | Ingombota | NA | AGO.11.3.2_1 | Ingombota | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.23304 -8.81091, 13.23416 -8.81764... |
305 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.3_1 | Ingombota | NA | AGO.11.3.3_1 | Kinanga | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.22656 -8.80957, 13.22361 -8.81403... |
306 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.3_1 | Ingombota | NA | AGO.11.3.4_1 | Maculusso | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.23116 -8.82300, 13.23416 -8.81764... |
307 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.3_1 | Ingombota | NA | AGO.11.3.5_1 | Patrice Lumumba | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.25614 -8.80953, 13.24937 -8.80831... |
308 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.4_1 | Kilamba Kiaxi | NA | AGO.11.4.1_1 | Kilamba Kiaxi | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.27703 -8.84495, 13.28397 -8.84877... |
309 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.5_1 | Maianga | NA | AGO.11.5.1_1 | Cassequel | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.23851 -8.83129, 13.24350 -8.82758... |
310 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.5_1 | Maianga | NA | AGO.11.5.2_1 | Maianga | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.22631 -8.82103, 13.23116 -8.82300... |
311 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.5_1 | Maianga | NA | AGO.11.5.3_1 | Prenda | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.24709 -8.85091, 13.24222 -8.85261... |
312 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.6_1 | Rangel | NA | AGO.11.6.1_1 | Marcal | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.25231 -8.82266, 13.25545 -8.81734... |
313 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.6_1 | Rangel | NA | AGO.11.6.2_1 | Rangel | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.27115 -8.81709, 13.27492 -8.82195... |
314 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.6_1 | Rangel | NA | AGO.11.6.3_1 | Terra Nova | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.27518 -8.83783, 13.27703 -8.84495... |
315 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.7_1 | Samba | NA | AGO.11.7.1_1 | Benfica | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.13801 -8.96194, 13.14442 -8.96578... |
316 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.7_1 | Samba | NA | AGO.11.7.2_1 | Futungo de Belas | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.19239 -8.89461, 13.19973 -8.89653... |
317 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.7_1 | Samba | NA | AGO.11.7.3_1 | Mussulo | NA | NA | Commune | Commune | NA | NA | MULTIPOLYGON (((13.01318 -9.11990, 13.00907 -9... |
318 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.7_1 | Samba | NA | AGO.11.7.4_1 | Samba | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.21492 -8.83055, 13.22101 -8.83078... |
319 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.8_1 | Sambizanga | NA | AGO.11.8.1_1 | N'gola Kilwanji | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.30326 -8.75798, 13.30523 -8.76749... |
320 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.8_1 | Sambizanga | NA | AGO.11.8.2_1 | Sambizanga | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.27810 -8.79838, 13.27602 -8.80478... |
321 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.9_1 | Viana | NA | AGO.11.9.1_1 | Calumbo | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.48907 -8.99619, 13.48733 -9.00185... |
322 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.9_1 | Viana | NA | AGO.11.9.2_1 | Viana | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.30250 -9.15576, 13.28976 -9.17134... |
323 | AGO | Angola | AGO.11_1 | Luanda | NA | AGO.11.9_1 | Viana | NA | AGO.11.9.3_1 | Viana Sede | NA | NA | Commune | Commune | NA | NA | POLYGON ((13.53484 -8.88864, 13.52679 -8.89795... |
# plot luanda2
luanda2.plot(color='orange', edgecolor='black')
plt.show()
# merge luanda2 to be one polygon
luanda2clean = luanda2.dissolve(by='NAME_1')
# plot luanda2clean
luanda2clean.plot(color='orange', edgecolor='black')
plt.show()
# export data folder path
export = (path + 'exports/')
# export as geojson
luanda2clean.to_file(export + 'luanda2clean.geojson', driver='GeoJSON')