-
大小: 4KB文件类型: .py金币: 2下载: 1 次发布日期: 2021-06-08
- 语言: Python
- 标签: python basemap matplotlib
资源简介
ArcGIS出图有时候不好看,运用Basemap可以将shapefile加入到图片中,出图既美观又方便。
代码片段和文件信息
from mpl_toolkits.basemap import basemap
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
from matplotlib.patches import PathPatch
import pandas as pd
from dbfread import DBF
from mpl_toolkits.axes_grid1.inset_locator import inset_axes zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
from adjustText import adjust_text
import matplotlib.ticker as ticker
plt.style.use(‘boorn‘)
plt.rcParams[‘mathtext.default‘]=‘regular‘
plt.rc(‘font‘family=‘Arial‘size = 6weight=‘bold‘)
fig = plt.figure(dpi=600)
ax = fig.add_subplot(111)
bmap = basemap(epsg=2380llcrnrlon=79llcrnrlat=16
urcrnrlon=139urcrnrlat=51lat_0=33.5
lon_0=109resolution=‘l‘ax=axwidth=5height=7.0*5/8)
#bmap.drawcoastlines(linewidth=0.25color=‘b‘)
bmap.drawcountries(linewidth=0.7color=‘k‘)
bmap.drawstates(linewidth=0.5color=‘r‘)
bmap.drawcounties(linewidth=0.5color=‘k‘)
bmap.drawrivers(linewidth=0.1color=‘#a6c2de‘)
bmap.drawmapboundary(fill_color=‘#a6c2de‘linewidth=0.5)
text={‘rotation‘:‘vertical‘}
bmap.drawmeridians(np.arange(7913910)labels=[0001]linewidth=0.5)
bmap.drawparallels(np.arange(165110)labels=[0100]linewidth=0.5**text)
bmap.fillcontinents(color=‘w‘lake_color=‘#a6c2de‘zorder=1)
bmap.readshapefile(‘e:/data/china_province_boundary/province‘
‘province‘color=‘#999999‘linewidth=0.3)
patches = []
for info shape in zip(bmap.province_info bmap.province):
patches.append(Polygon(np.array(shape) True))
ax.add_collection(
PatchCollection(patches facecolor= ‘#fff8dc‘ edgecolor=‘#4F4F4F‘
linewidths=0.5 zorder=2))
city_info = bmap.readshapefile(‘e:/research/NDVI_LST/data/shapefile/city30‘‘city‘)
df = pd.Dataframe(iter(DBF(‘e:/research/NDVI_LST/data/shapefile/city30.dbf‘)))
text={‘ha‘:‘center‘‘va‘:‘top‘}
texts=[]
for city_info city in zip(bmap.city_info bmap.city):
bmap.plot(city[0] city[1] marker=‘.‘ color=‘r‘ markersize=4 markeredgewidth=1)
if city_info[‘cityname‘]==‘Wuhn‘:
texts.append(plt.text(city[0]city[1]‘Wuhan‘
相关资源
- python实现SGBM图像匹配算法
- python实现灰度直方图均衡化
- scrapy_qunar_one
- Python学习全系列教程永久可用
- python简明教程.chm
- 抽奖大转盘python的图形化界面
- 双边滤波器实验报告及代码python
- python +MYSQL+HTML实现21蛋糕网上商城
- Python-直播答题助手自动检测出题搜索
- OpenCV入门教程+OpenCV官方教程中文版
- Python 串口工具源码+.exe文件
- Python开发的全栈股票系统.zip
- Python操作Excel表格并将其中部分数据写
- python书籍 PDF
- 利用python绘制散点图
- python+labview+No1.vi
- 老男孩python项目实战
- python源码制作whl文件.rar
- python3.5可用的scipy
- PYTHON3 经典50案例.pptx
- 计算机科学导论-python.pdf
- python模拟鼠标点击屏幕
- windows鼠标自动点击py脚本
- 鱼c小甲鱼零基础学python全套课后题和
- Python 练习题100道
- Practical Programming 2nd Edition
- wxPython Application Development Cookbook
- python 3.6
- Python 3.5.2 中文文档 互联网唯一CHM版本
- python3.5.2.chm官方文档
评论
共有 条评论