欢迎来到Python教程自学网!
当前位置: 首页 > Python基础教程 > 如何使用python中basemap库绘制地图?

如何使用python中basemap库绘制地图?

   

basemap库能够实现绘制地图这是毋庸置疑的,因为库的本身的最大作用就是实现地图绘制,在Matplotlib工具库中存在着很多可以实现数据可视化的库,但是唯一让我们在地图绘制上,去选取的库只有basemap,上期我们说过了安装技巧,本章给大家介绍是如何使用,一起来详细了解下吧。

第一步、python脚本画世界地图

import matplotlib.pyplot as pit
from mpl_toolkits.basemap import Basemap
pit.figure(figsize=(16,8))
map = Basemap()
map.drawcoastlines()
pit.show()

运行结果:

第二步、增加一行代码

map.drawcountries(linewidth=1.5)

运行效果:

<img width=”554″ height=”280″ src=”https://www.python51.com/4AAQSkZJRgABAQEAYABgAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAEYAioDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVV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