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()
    
  • 相关阅读:
    LeetCode Count of Range Sum
    LeetCode 158. Read N Characters Given Read4 II
    LeetCode 157. Read N Characters Given Read4
    LeetCode 317. Shortest Distance from All Buildings
    LeetCode Smallest Rectangle Enclosing Black Pixels
    LeetCode 315. Count of Smaller Numbers After Self
    LeetCode 332. Reconstruct Itinerary
    LeetCode 310. Minimum Height Trees
    LeetCode 163. Missing Ranges
    LeetCode Verify Preorder Serialization of a Binary Tree
  • 原文地址:https://www.cnblogs.com/dengz/p/14835578.html
Copyright © 2011-2022 走看看