(Python)绘制地理坐标范围与点

import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
import numpy as np
#plt.rcParams["font.family"]="SimHei" #正常显示中文


def drawBoundary(ax, boundary, **kw):
    """
    绘制地理坐标区域
    :param ax: 绘制的坐标轴
    :param boundary: 待绘制的地理区域(必需为四角标依次存储)
    """
    verts = list(boundary)
    verts.append(verts[0])
    codes = [
        Path.MOVETO,
        Path.LINETO,
        Path.LINETO,
        Path.LINETO,
        Path.CLOSEPOLY
    ]
    path = Path(verts, codes)
    patch = patches.PathPatch(path, facecolor='g', alpha=0.05)
    ax.add_patch(patch)

#第一步创建图形画板和图
fig, ax = plt.subplots()
boundary = [
    (34.914937, 112.913792),  # 矩形左下角的坐标(left,bottom)
    (34.816718, 113.460402),  # 矩形左上角的坐标(left,top)
    (34.375733, 113.342728),  # 矩形右上角的坐标(right,top)
    (34.473672, 112.799020) ]# 矩形右下角的坐标(right, bottom)]  # 封闭到起点
params = 'g-'
#绘制一张影像的地理边界
drawBoundary( ax, boundary,linestyle = '--',linewidth = 1,label='boundary',color = 'b')

tie_ponits= np.array([[34.477728	, 112.972514,	466.250588],
         [34.475660,112.977638	,443.428995],
         [34.472156	,113.011141,	440.242173]])

ax.scatter(tie_ponits[:,0],tie_ponits[:,1],label='tie_points',color = 'y',marker = '*', s=20)
ax.legend(loc=4,fontsize=8)

#图的参数设置
ax.set_title("Layout",fontsize=12,verticalalignment="baseline")#标题(表头)
plt.tick_params()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
#ax.spines['top'].set_color('none')
#ax.tick_params(labelsize='small')
ax.axis('equal')
plt.show()

在这里插入图片描述

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值