21.12.2022 Views

python_para_desenvolvedores_2ed

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Processamento numérico 209

mapa.drawmeridians(arange(0, 360, 30), color='#ccccee')

# Desenha os paralelos

mapa.drawparallels(arange(-180, 180, 30), color='#ccccee')

# Desenha os limites do mapa

mapa.drawmapboundary()

# Salva a imagem

pyplot.savefig('mapa1.png', dpi=150)

Saída:

Outro exemplo:

from mpl_toolkits.basemap import Basemap

from matplotlib import pyplot

mapa = Basemap(projection='ortho', lat_0=10, lon_0=-10,

resolution='l', area_thresh=1e3)

# Preenche o mapa com relevo

mapa.bluemarble()

mapa.drawmapboundary()

lxy = (('Rio\nde\nJaneiro', -43.11, -22.54),

('Londres', 0.07, 50.30))

# Transposta

lxy = zip(*lxy)

# Converte as coordenadas

x, y = mapa(lxy[1], lxy[2])

lxy = lxy[0], x, y

# Marca no mapa

mapa.plot(x, y, 'w^')

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!