forked from acamargo96/jogo-cidades-br
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps.py
31 lines (23 loc) · 1.19 KB
/
maps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.io.shapereader as shpreader
class Mapa():
def __init__(self):
self.fig = plt.figure(figsize=(15, 10))
self.ax = self.fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree(central_longitude=0))
self.ax.set_extent((-80, -30, -40, 15))
self.ax.coastlines()
# Fonte: https://gis.stackexchange.com/questions/88209/python-mapping-in-matplotlib-cartopy-color-one-country
shpfilename = shpreader.natural_earth(resolution='110m',
category='cultural',
name='admin_0_countries')
reader = shpreader.Reader(shpfilename)
countries = reader.records()
for country in countries:
if country.attributes['NAME_EN'] == 'Brazil':
self.ax.add_geometries([country.geometry], ccrs.PlateCarree(),
facecolor='#C8D5B9',
label=country.attributes['NAME_EN'])
self.ax.add_feature(cfeature.BORDERS)
self.ax.add_feature(cfeature.OCEAN)