Skip to content
Snippets Groups Projects
Commit 16f38c01 authored by Quentin ANDRE's avatar Quentin ANDRE
Browse files

get_countries

parent d37c7ce4
No related branches found
No related tags found
No related merge requests found
import cartopy.crs as ccrs
import cartopy.feature as cf
from cartopy.feature import ShapelyFeature
from matplotlib import pyplot as plt
import cartopy.io.shapereader as shpreader
proj = ccrs.PlateCarree()
ax = plt.axes(projection=proj)
# Show only Africa
#ax.set_extent([-23, 55, -35, 40])
ax.stock_img()
ax.add_feature(cf.COASTLINE, lw=2)
# Make figure larger
plt.gcf().set_size_inches(20, 10)
# Read shape file
shpfilename = shpreader.natural_earth(resolution='10m',
......@@ -26,10 +16,9 @@ kenya = [country for country in reader.records() if country.attributes["NAME_LON
# Determine bounding box
lon_min, lat_min, lon_max, lat_max = kenya.bounds
ax.set_extent([lon_min, lon_max, lat_min, lat_max])
print(kenya.bounds)
# Display Kenya's shape
shape_feature = ShapelyFeature([kenya.geometry], ccrs.PlateCarree(), facecolor="lime", edgecolor='black', lw=1)
ax.add_feature(shape_feature)
plt.show()
\ No newline at end of file
print(shape_feature)
print(kenya.geometry)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment