博客
关于我
Python数据可视化:Cartopy 地理空间数据可视化
阅读量:634 次
发布时间:2019-03-14

本文共 3404 字,大约阅读时间需要 11 分钟。

igs 站点分布图绘制教程

Cartopy 是一个为 Python 开发的地图绘制库,基于 matplotlib 提供简单直观的地理功能操作。通过 Cartopy,我们可以轻松绘制各种地理图形,包括站点分布图、控制网以及板块分布图。本文将分别介绍如何使用 Cartopy 绘制 IGS 核心站与 MGEX 站点分布图、GNSS 控制网以及板块分布图。


1. IGS 核心站与 MGEX 站点分布图

IGS 核心站与 MGEX 站点分布图主要展示全球 IGS 核心站和 MGEX 项目站点的位置分布。以下是绘制步骤:

import numpy as npimport matplotlib.pyplot as pltimport cartopy.crs as ccrsimport cartopy.feature as cfeature# 加载 IGS 核心站和 MGEX 站点坐标数据igs_core = np.recfromcsv('igs-core.csv', names=True, encoding='utf-8')mgex = np.recfromcsv('mgex.csv', names=True, encoding='utf-8')# 创建图像fig = plt.figure(figsize=[9, 6])ax = plt.axes(projection=ccrs.Robinson())# 添加海洋和陆地特征ax.add_feature(cfeature.LAND)ax.add_feature(cfeature.OCEAN)# 绘制 IGS 核心站和 MGEX 站点ax.plot(mgex['longitude'], mgex['latitude'], 'o', color='tomato', label='MGEX', transform=ccrs.Geodetic())ax.plot(igs_core['longitude'], igs_core['latitude'], '*', color='darkmagenta', label='IGS Core', transform=ccrs.Geodetic())# 添加网格ax.gridlines(linestyle='--')# 设置全局范围ax.set_global()# 添加图例plt.legend(loc='lower right')# 显示图像plt.show()

2. GNSS 控制网绘制

GNSS 控制网是通过 Delaunay 三角剖分技术生成的几何图形,用于展示全球 GNSS 站点的空间分布。以下是详细步骤:

import numpy as npimport matplotlib.pyplot as pltimport matplotlib.tri as triimport cartopy.crs as ccrsimport cartopy.feature as cfeature# 加载 IGS 站点坐标数据igs_sites = np.recfromcsv('euro-igs.csv', names=True, encoding='utf-8')# 生成 Delaunay 三角剖分triangles = tri.Triangulation(igs_sites['longitude'], igs_sites['latitude'])# 创建图像fig = plt.figure(figsize=[6, 8])ax = plt.axes(projection=ccrs.LambertConformal(central_latitude=90, central_longitude=10))# 添加地理特征ax.add_feature(cfeature.OCEAN.with_scale('50m'))ax.add_feature(cfeature.LAND.with_scale('50m'))ax.add_feature(cfeature.RIVERS.with_scale('50m'))ax.add_feature(cfeature.LAKES.with_scale('50m'))# 绘制 Delaunay 三角剖分网格plt.triplot(triangles, transform=ccrs.Geodetic(), marker='o', linestyle='-')# 添加网格ax.gridlines(linestyle='--')# 设置图像范围ax.set_extent([-10, 30, 30, 73])# 显示图像plt.show()

3. Nuvel 板块分布图绘制

Nuvel 板块分布图展示全球主要板块的边界及其名称。以下是详细步骤:

import numpy as npimport matplotlib.pyplot as pltimport cartopy.crs as ccrsimport cartopy.feature as cfeature# 加载板块边界数据文件files = ['African.txt', 'Antarctic.txt', 'Arabian.txt', 'Australian.txt',         'Caribbean.txt', 'Cocos.txt', 'Eurasian.txt', 'Indian.txt',         'Juan.txt', 'Nazca.txt', 'North_Am.txt', 'Pacific.txt',         'Philippine.txt', 'Scotia.txt', 'South_Am.txt']# 读取边界数据borders = []for f in files:    border = np.genfromtxt(f, names=['lon', 'lat'], dtype=float, comments=':')    borders.append(border)# 定义板块名称和中心点坐标plates = ['African', 'Antarctic', 'Arabian', 'Australian', 'Caribbean', 'Cocos',          'Eurasian', 'Indian', 'Juan', 'Nazca', '  North\nAmerican', 'Pacific',          'Philippine', 'Scotia', '  South\nAmerican']central = [(17, -5), (90, -80), (40, 21), (120, -28), (270, 12), (260, 6),          (60, 50), (70, 13), (230, 45), (260, -21), (250, 36), (190, 0),          (123, 17), (304, -59), (315, -27)]# 创建图像fig = plt.figure(figsize=(12, 7))ax = plt.axes(projection=ccrs.Mollweide(central_longitude=120))# 添加背景图像ax.stock_img()# 绘制板块边界并添加名称for plate, center, border in zip(plates, central, borders):    ax.plot(border['lon'], border['lat'], color='coral', transform=ccrs.Geodetic())    ax.text(center[0], center[1], plate, transform=ccrs.Geodetic())# 添加网格ax.gridlines(linestyle='--')# 显示图像plt.show()

以上是使用 Cartopy 绘制三种地理图形的教程。通过以上代码示例,读者可以轻松掌握 Cartopy 的基本使用方法,并根据需求进行图形定制。

转载地址:http://rsioz.baihongyu.com/

你可能感兴趣的文章
Node-RED中使用node-random节点来实现随机数在折线图中显示
查看>>
Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
查看>>
Node-RED中使用node-red-contrib-image-output节点实现图片预览
查看>>
Node-RED中使用node-red-node-ui-iframe节点实现内嵌iframe访问其他网站的效果
查看>>
Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
查看>>
Node-RED中使用range范围节点实现从一个范围对应至另一个范围
查看>>
Node-RED中实现HTML表单提交和获取提交的内容
查看>>
Node-RED中将CSV数据写入txt文件并从文件中读取解析数据
查看>>
Node-RED中建立TCP服务端和客户端
查看>>
Node-RED中建立Websocket客户端连接
查看>>
Node-RED中建立静态网页和动态网页内容
查看>>
Node-RED中解析高德地图天气api的json数据显示天气仪表盘
查看>>
Node-RED中连接Mysql数据库并实现增删改查的操作
查看>>
Node-RED中通过node-red-ui-webcam节点实现访问摄像头并截取照片预览
查看>>
Node-RED中配置周期性执行、指定时间阶段执行、指定时间执行事件
查看>>
Node-RED安装图形化节点dashboard实现订阅mqtt主题并在仪表盘中显示温度
查看>>
Node-RED怎样导出导入流程为json文件
查看>>
Node-RED订阅MQTT主题并调试数据
查看>>
Node-RED通过npm安装的方式对应卸载
查看>>
node-request模块
查看>>