zoukankan      html  css  js  c++  java
  • chinaMap

    中国地图

    基本地图

    import pandas as pd
    from matplotlib.colors import rgb2hex
    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    
    ### 1. 中国基本地图
    map = Basemap(
    	llcrnrlon=77,
    	llcrnrlat=14,
    	urcrnrlon=140,
    	urcrnrlat=51,
    	projection='lcc',
    	lat_1=33,
    	lat_2=45,
    	lon_0=100
    )
    
    map.drawcountries(linewidth=1.5)
    map.drawcoastlines()
    plt.show()
    

    城市地图

    import pandas as pd
    from matplotlib.colors import rgb2hex
    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    from matplotlib.patches import Polygon
    import pandas as pd
    cmap = plt.cm.YlOrRd
    
    map = Basemap(
       llcrnrlon=77,
       llcrnrlat=14,
       urcrnrlon=140,
       urcrnrlat=51,
       projection='lcc',
       lat_1=33,
       lat_2=45,
       lon_0=100
    )
    map.readshapefile("./gadm36_CHN_shp/gadm36_CHN_2", 'states', drawbounds=True)
    map.readshapefile("./gadm36_TWN_shp/gadm36_TWN_2", 'taiwan', drawbounds=True)
    
    map.drawcoastlines()
    map.drawcountries(linewidth=1.5)
    
    plt.show()
    
    pd.read_excel('./gadm36_TWN_shp/A0101a.xls') 
    
    statenames = []
    colors = {}
    
    
    vmax = 100000000
    vmin = 2000000
    
    for shapedict in map.states_info:
    	statenme = shapedict['NL_NAME1']
    	p = statenme.split("|")
    	print p
    

    地图上色

    from matplotlib.patches import Polygon
    from matplotlib.colors import rgb2hex
    import pandas as pd
    from matplotlib.colors import rgb2hex
    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    
    map = Basemap(
    	llcrnrlon=77,
    	llcrnrlat=14,
    	urcrnrlon=140,
    	urcrnrlat=51,
    	projection='lcc',
    	lat_1=33,
    	lat_2=45,
    	lon_0=100
    )
    map.readshapefile("./gadm36_CHN_shp/china",'china',drawbounds=True)
    map.readshapefile("./gadm36_CHN_shp/china_nine_dotted_line",'nine_dotted',drawbounds=True)
    cmap = plt.cm.YlOrRd
    ax = plt.gca()
    for nshape,seg in enumerate(map.china):
    	color = rgb2hex(cmap(nshape)[:3])
    	poly = Polygon(seg,facecolor=color,edgecolor=color)
    	ax.add_patch(poly)
    plt.show()
    
    provinces = set()
    
    #  china_info 是 地图中的省份信息
    for shapdict in map.china_info:
    	statename = shapdict['OWNER']
    	provinces.add(statename.replace('x00',''))
    print provinces
    stations_lon_lat  = pd.read_csv()
    
  • 相关阅读:
    SAP全球企业官孙小群的生活智慧
    C++ vs Python向量运算速度评测
    C++ Error: no appropriate default constructor available
    危险的浮点数float
    Vagrant 手册之 Vagrantfile
    MySQL 服务器性能剖析
    Vagrant 手册之多个虚拟机 multi-machine
    Vagrant 手册之同步目录
    Vagrant 手册之同步目录
    MySQL 中的 information_schema 数据库
  • 原文地址:https://www.cnblogs.com/dengz/p/14835578.html
Copyright © 2011-2022 走看看