Professional Documents
Culture Documents
%matplotlib inline
In [ ]: world_data = gpd.read_file(r'world.shp')
world_data
Out[5]: FIPS ISO2 ISO3 UN NAME AREA POP2005 REGION SUBREGION LON LAT geometry
0 AC AG ATG 28 Antigua and Barbuda 44 83039 19 29 -61.783 17.078 MULTIPOLYGON (((-61.68667 17.02444, -61.73806 ...
1 AG DZ DZA 12 Algeria 238174 32854159 2 15 2.632 28.163 POLYGON ((2.96361 36.80222, 2.98139 36.80694, ...
2 AJ AZ AZE 31 Azerbaijan 8260 8352021 142 145 47.395 40.430 MULTIPOLYGON (((45.08332 39.76804, 45.26639 39...
3 AL AL ALB 8 Albania 2740 3153731 150 39 20.068 41.143 POLYGON ((19.43621 41.02107, 19.45055 41.06000...
4 AM AM ARM 51 Armenia 2820 3017661 142 145 44.563 40.534 MULTIPOLYGON (((45.57305 40.63249, 45.52888 40...
... ... ... ... ... ... ... ... ... ... ... ... ...
241 TB BL BLM 652 Saint Barthelemy 0 0 19 29 -63.043 18.040 POLYGON ((-63.02834 18.01555, -63.03334 18.015...
242 GK GG GGY 831 Guernsey 0 0 150 154 -2.576 49.459 POLYGON ((-2.59083 49.42249, -2.59722 49.42249...
243 JE JE JEY 832 Jersey 0 0 150 154 -2.129 49.219 POLYGON ((-2.01500 49.21416, -2.02111 49.17722...
244 SX GS SGS 239 South Georgia South Sandwich Islands 0 0 0 0 -36.891 -54.209 MULTIPOLYGON (((-27.32584 -59.42722, -27.29806...
245 TW TW TWN 158 Taiwan 0 0 0 0 120.946 23.754 MULTIPOLYGON (((121.57639 22.00139, 121.57027 ...
world_data.plot()
In [ ]:
In [ ]: world_data1 = world_data[['NAME','geometry']]
world_data1
244 South Georgia South Sandwich Islands MULTIPOLYGON (((-27.32584 -59.42722, -27.29806...
In [ ]: world_data1['area']=world_data.area
<ipython-input-8-24e460c98e5b>:1: UserWarning: Geometry is in a geographic CRS. Results from 'area' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries
to a projected CRS before this operation.
world_data1['area']=world_data.area
/usr/local/lib/python3.9/dist-packages/geopandas/geodataframe.py:1443: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
244 South Georgia South Sandwich Islands MULTIPOLYGON (((-27.32584 -59.42722, -27.29806... 0.542074
world_data1.plot(column='NAME', cmap='hsv')
/usr/local/lib/python3.9/dist-packages/geopandas/geodataframe.py:1443: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
In [ ]: world_data1.plot(column='area', cmap='hsv')
In [ ]: world_data1['area']=world_data1.area/1000000
/usr/local/lib/python3.9/dist-packages/geopandas/geodataframe.py:1443: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
In [ ]: data = df_new[df_new['migencode']=='TOT'][['condesname','2000']]
data
26 Canada 313999
27 Australia 94110
28 Denmark 4400
29 Finland 1136
30 France 136233
31 Germany 35486
32 Netherlands 10834
34 Singapore 105187
35 Sweden 10988
36 Switzerland 6419
Out[19]: FIPS ISO2 ISO3 UN NAME AREA POP2005 REGION SUBREGION LON LAT geometry condesname 2000
0 AS AU AUS 36 Australia 768230 20310208 9 53 136.189 -24.973 MULTIPOLYGON (((158.88217 -54.71139, 158.87967... Australia 94110
1 CA CA CAN 124 Canada 909351 32270507 19 21 -109.433 59.081 MULTIPOLYGON (((-65.61362 43.42027, -65.61972 ... Canada 313999
2 DA DK DNK 208 Denmark 4243 5416945 150 154 9.264 56.058 MULTIPOLYGON (((11.51389 54.82972, 11.56444 54... Denmark 4400
3 FI FI FIN 246 Finland 30459 5246004 150 154 26.272 64.504 MULTIPOLYGON (((23.70583 59.92722, 23.64944 59... Finland 1136
4 FR FR FRA 250 France 55010 60990544 150 155 2.550 46.565 MULTIPOLYGON (((9.48583 42.61527, 9.49472 42.6... France 136233
In [ ]: merged_df.plot(column='2000', cmap='hsv',legend=True,
legend_kwds={'label': 'Density of Emigrants'},
figsize=(7,7))
plt.title('Indian migrants by Country (Year 2000)')
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.xlim(-180.433,180.235)
plt.ylim(-55.634,90.504)
plt.show()