zoukankan      html  css  js  c++  java
  • python工具——basemap使用一基本使用

    basemap基于GEOS的地图二维数据,其底图数据库与GMT相同,封装了大量常用的地图投影、坐标转换功能,利用简洁的Python语法支持绘出多种多样的地理地图

    1.安装

    基于geos的,先安装geos

    pip install geos

    https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载 

    basemap-1.2.2-cp37-cp37m-win_amd64.whl

    注:

      cp后面的数字是Python的版本,根据自己的python版本来

    安装

    pip install basemap-1.2.2-cp37-cp37m-win_amd64.whl --default-timeout=200

    eg:

    绘制最简单的地图

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    
    map = Basemap()
    
    map.drawcoastlines()
    
    plt.show()
    plt.savefig('test.png')

     可以给陆地和海洋填上不同的颜色

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    
    map = Basemap(projection='ortho', 
                  lat_0=0, lon_0=0)
    
    #Fill the globe with a blue color 
    map.drawmapboundary(fill_color='aqua')
    #Fill the continents with the land color
    map.fillcontinents(color='coral',lake_color='aqua')
    
    map.drawcoastlines()
    
    plt.show()

     绘制国家边界

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    
    map = Basemap(projection='ortho', 
                  lat_0=0, lon_0=0)
    
    map.drawmapboundary(fill_color='aqua')
    map.fillcontinents(color='coral',lake_color='aqua')
    
    map.drawcountries()
    
    plt.show()

    官网

    https://basemaptutorial.readthedocs.io/en/latest/first_map.html

  • 相关阅读:
    后续阶段第二天
    后续阶段第一天
    冲刺第五天
    冲刺第四天
    冲刺第三天
    冲刺第二天
    第二阶段-冲刺第一天
    第一阶段项目总结
    冲刺(7)
    团队开发冲刺第一阶段_6
  • 原文地址:https://www.cnblogs.com/baby123/p/14235758.html
Copyright © 2011-2022 走看看