码迷,mamicode.com
首页 > 其他好文 > 详细

chinaMap

时间:2021-06-02 19:40:47      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:lan   bounds   too   enme   imp   map   max   sem   replace   

中国地图

基本地图

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()

chinaMap

标签:lan   bounds   too   enme   imp   map   max   sem   replace   

原文地址:https://www.cnblogs.com/dengz/p/14835578.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!