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()
posted @ 2021-06-01 08:56  染指未来  阅读(402)  评论(0编辑  收藏  举报