In [1]:
import geopandas
import pandas as pd
import matplotlib.pyplot as plt
In [2]:
geopandas.datasets.available
Out[2]:
In [3]:
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
In [4]:
world.head()
Out[4]:
In [5]:
world.plot();
In [6]:
world.plot(figsize=(15, 15))
Out[6]:
In [7]:
ax = world.plot(figsize=(15, 15))
ax.set_axis_off()
In [8]:
world1 = world[(world['pop_est'] > 0 ) & (world['name'] != "Antarctica")]
world1.head()
Out[8]:
In [9]:
ax = world1.plot(figsize=(15, 15))
ax.set_axis_off()
In [10]:
world2 = world[(world['continent'] == "Asia")]
world2.head()
Out[10]:
In [11]:
ax = world2.plot(figsize=(15, 15))
ax.set_axis_off()
In [12]:
world3 = world[(world['continent'] != "Asia")]
world3.head()
Out[12]:
In [13]:
ax = world3.plot(figsize=(15, 15))
ax.set_axis_off()
In [14]:
usa = world[world['name'] == 'United States of America']
usa.plot()
Out[14]:
In [15]:
usaContinent = world[world['continent'] == 'North America']
usaContinent
Out[15]:
In [16]:
usaContinent.plot()
Out[16]:
In [17]:
india = world[world['name'] == 'India']
india.plot()
Out[17]:
In [18]:
nepal = world[world['name'] == 'Nepal']
nepal.plot()
Out[18]:
In [19]:
pakistan = world[world['name'] == 'Pakistan']
pakistan.plot()
Out[19]:
In [20]:
africa = world[world['continent'] == 'Africa']
In [21]:
africa
Out[21]:
In [22]:
africa.plot()
Out[22]:
In [23]:
cities = geopandas.read_file(
geopandas.datasets.get_path("naturalearth_cities")
)
In [24]:
cities
Out[24]:
In [25]:
ax = world.plot(figsize=(15, 15))
cities.plot(ax=ax, color='red', markersize=10)
ax.set_axis_off()
In [26]:
paris = cities[cities['name'] == 'Paris']
paris.plot()
Out[26]:
In [27]:
ax = world.plot(figsize=(15, 15))
paris.plot(ax=ax, color='red', markersize=10)
ax.set_axis_off()
In [28]:
singapore = cities[cities['name'] == 'Singapore']
singapore.plot()
Out[28]:
In [29]:
ax = world.plot(figsize=(15, 15))
singapore.plot(ax=ax, color='red', markersize=20)
ax.set_axis_off()
In [30]:
delhi = cities[cities['name'] == 'New Delhi']
delhi.plot()
Out[30]:
In [31]:
ax = india.plot(figsize=(15, 15))
delhi.plot(ax=ax, color='red', markersize=20)
ax.set_axis_off()