背景
最近河南文旅大伙,给家乡带了一波热度,想想又是王子又是公主,着实羡慕。出门在外,还是对加很有感觉得,不过很遗憾,本人不能为家乡做出贡献,只能使用这种小伎俩,稍稍展示,稍作关联。
环境和数据准备
安装 gma:
pip install gma
本文基于:gma 2.0.5,Python 3.11
本文用到的矢量数据为:
链接:https://pan.baidu.com/s/1_jP6qXle1ixnWo_A_kjEYQ?pwd=w9vu
提取码:w9vu
绘图目标
代码
from gma import io
from gma.map import plotSYG = io.ReadVector('上阳宫.shp')
SYG_M = io.ReadVector('上阳宫_门.shp')CQ = io.ReadVector('城墙.shp')
CM = io.ReadVector('城门.shp')
TWC = io.ReadVector('太微城.shp')
Q = io.ReadVector('桥.shp')
LS = io.ReadVector('洛水(涧水).shp')
ZWC = io.ReadVector('紫微城.shp')
LF = io.ReadVector('里坊.shp')MapF = plot.MapFrame(BaseMapProj = SYG.Projection)MapSYG = MapF.AddLayer(SYG, FaceColor = '#D7FCDC')MapLF = MapF.AddLayer(LF, FaceColor = '#DCCFFC')
MapTWC = MapF.AddLayer(TWC, FaceColor = '#FCCAB3')
MapZWC = MapF.AddLayer(ZWC, FaceColor = '#FFD37F')MapCQ = MapF.AddLayer(CQ, LineColor = '#31B07D', LineWidth = 0.6, Zorder = 5)MapLS = MapF.AddLayer(LS, FaceColor = '#BEE8FF', LineWidth = 0.1)MapSYG_M = MapF.AddLayer(SYG_M, PointColor = '#89438C', PointSize = 4, Zorder = 8, FieldName = '门')
SYG_MLabel = MapSYG_M.AddLabel(Font = 'SimSun', FontSize = 5, Offset = (-30, 10), Zorder = 9)MapCM = MapF.AddLayer(CM, PointColor = '#58992F', PointSize = 4, Zorder = 10, FieldName = '城门')
CMLabel = MapCM.AddLabel(Font = 'SimSun', FontSize = 5, Offset = (-30, 10), Zorder = 11)MapQ = MapF.AddLayer(Q, LineColor = '#22A19A', LineWidth = 0.6, Zorder = 12, FieldName = '桥')
QLabel = MapQ.AddLabel(Font = 'SimSun', FontSize = 5, Zorder = 13, Position = 'Geometric')