gma 地理空间绘图:(1)绘制简单的世界地图-1.地图绘制与细节调整

news2024/9/23 9:30:57

了解 gma

gma 是什么?

gma 是一个基于 Python 的地理、气象数据快速处理和数据分析函数包(Geographic and Meteorological Analysis,gma)。gma 网站:地理与气象分析库。

gma 的主要功能有哪些?

气候气象(例如 SPEI、SPI、ET0 等)。
遥感指数(例如 NDVI、EVI、TVDI 等)。
数学运算(例如 数据平滑、评估、滤波、拉伸、增强变换等)。
系统交互(例如 获取路径、重命名、压缩等操作)。
空间杂项(例如 计算空间距离、面积计算,坐标转换、空间插值等操作)。
栅格处理(例如 栅格镶嵌、裁剪、重采样、重投影、格式转换、数据融合等)。
栅格分析(例如 DEM 坡度、坡向、阴影、等值线等计算)。
矢量处理(例如 矢量裁剪、擦除、交集、融合、重投影等)。
地图工具(例如 栅格、矢量数据绘图,指北针、比例尺等生成,坐标系定义等)

gma 的安装要求?

系统 (X64): Window 10+,Linux
Python 版本: 3.8.8 ~ 3.10,建议使用 3.9

gma 哪个版本开始支持空间绘图?

gma 1.1.2 及之后的版本
点击查看:gma 1.1.2 版本的新增内容

基于 gma 绘制简单的世界地图

本文基于 gma 1.1.2 (Python 3.9) ,为大家展示绘制世界地图(gma 内置的世界国家和地区),如果有自有的高精度世界地图,也可按照此方法绘制。

1. 绘制世界地图

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,用于绘图
MapF = plot.MapFrame(Axes = None, BaseMapProj = 'WGS84', Extent = None)

# 2.将内置的世界矢量图层添加到地图框 
MapL1 = MapF.AddLayer(WorldLayer)

请添加图片描述

2. 其他参数说明

自 gma 1.1.0 起,gma 不在内置中文帮助。

2.1 MapFrame 帮助

'''
Initialize a map frame for plotting a map!

**Optional
----------
Axes = None or matplotlib.~.AxesSubplot. Default None.
    A matplotlib subplot. If None, a default Axes will be created. 

BaseMapProj = str, int or SpatRef. Default 'WGS84'.
    Base map coordinate system. All data that added to this frame will be reprojected
    to this coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate
    characters or SpatRef(gma spatial reference) class.

Extent = list or None. Default None.
    Plot [left, bottom, right, top] extent(In WGS84). All data that added to this map
    frame will be clipped to this extent. Default(None) is the maximum extent supported
    by the base map coordinate system.
'''

在这里插入图片描述

2.2 AddLayer 帮助

'''
Add a layer to the map frame.

Parameters
----------
GMALayer: gma.algorithm.core.dataio.Layer.
    A vector layer opened by gma.Open(.GetLayer).

**Optional
----------
FID = list or None. Default None.
    The feature ID of the vector to plot. Default(None) all feature.
    For more, see gma.~.Layer.

FaceColor = str, tuplt, list or None. Default '#BED2FF'.
    The polygon fill color. Only for 'Polygon' layers. If None, a random color will
    be generated. If it is a list, assign a different color to each feature. For more,
    see matplotlib.

EdgeColor = str, tuplt, list or None. Default '#B2B2B2'.
    The polygon edge color. Only for 'Polygon' layers. If None, a random color will
    be generated. If it is a list, assign a different color to each feature.
    For more, see matplotlib.

Hatch = str, list or None. Default None.
    Filling style. May be {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} or a
    combination thereof. Only for 'Polygon' layers. Default(None) no filling style.
    If it is a list, assign a different hatch to each feature. For more, see matplotlib.

LineStyle = str, list, tuple, or None. Default None.
    Line style. May be {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}.If it is a list,
    assign a different line style to each feature. Default(None) no line style.
    For more, see matplotlib.

LineWidth = float or list. Default 0.5.
    Line width. In font-size units. If it is a list, assign a different
    line width to each feature. 

LineColor = str, tuplt, list or None. Default '#B2B2B2'.
    The line color. Only for 'Line' layers. If None, a random color will be generated.If
    it is a list, assign a different color to each feature. For more, see matplotlib.

PointColor = str, tuplt, list or None. Default '#BED2FF'.
    The point color. Only for 'Point' layers. If None, a random color will be generated.
    If it is a list, assign a different color to each feature. For more, see matplotlib.

PointSize = float, list or None. Default None.
    The point size. Only for 'Point' layers. If it is a list, assign a different size to each feature.
    Default(None) depends on the matplotlib setting.
    
PointMarker = str, list or None. Default None.
    The point marker. Only for 'Point' layers. Default(None) depends on the matplotlib setting.
    If it is a list, assign a different marker to each feature.

Labels = str or None. Default None.
    Manually set the feature labels. The number should be the same as the number of layer features.
    Otherwise, the shortfall will be assigned as null. Default(None) no labels.

FieldName = list, str or None. Default None.
    Layer field used to configure the label. If 'FieldName' is configured, 'Label' will be disabled.
    Default(None) no labels.

Connector = str. Default ''.
    If 'FieldName' configures more than one field, the fields are connected with this symbol.

Zorder = int or None. Default None.
    The layer order. Used to control the order of the layers. Default(None) depends on the
    matplotlib setting.

Returns
----------
gma.~.PlotLPolygon/PlotLLine/PlotLPoint.

'''

简单的世界地图细节调整

本例仅针对多边形的边界线、填充内容进行示例。其他参数参考2.2 进行调整和测试。

1. 调整边界线

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,用于绘图
MapF = plot.MapFrame(Axes = None, BaseMapProj = 'WGS84', Extent = None)

# 2.添加图层,并调整 边界线的颜色和线的宽度
MapL1 = MapF.AddLayer(WorldLayer, EdgeColor = 'gray', LineWidth = 0.2)

请添加图片描述

2. 调整填充色

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,用于绘图
MapF = plot.MapFrame(Axes = None, BaseMapProj = 'WGS84', Extent = None)

# 2.添加图层,并调整 填充颜色
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = 'gray')

请添加图片描述

3. 调整填充样式

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,用于绘图
MapF = plot.MapFrame(Axes = None, BaseMapProj = 'WGS84', Extent = None)

# 2.添加图层,并调整 填充样式
MapL1 = MapF.AddLayer(WorldLayer, Hatch = '*/')

请添加图片描述

4. 为每个国家或地区分配随机颜色

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,用于绘图
MapF = plot.MapFrame(Axes = None, BaseMapProj = 'WGS84', Extent = None)

# 2.添加图层,并为每个国家或地区分配随机颜色
### FaceColor = None 相当于生成了一个颜色列表,列表中的每个颜色都是随机的。
### 列表颜色数量与国家或地区数量相同(所有类似的参数均可按照此说明配置)。
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = None)

请添加图片描述

地图框控制

1. 调整底图坐标系

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,调整底图坐标系为 WGS 84 / Pseudo-Mercator(EPSG: 3857)
### 又名 web墨卡托投影,Spherical Mercator, Google Maps, OpenStreetMap, Bing, ArcGIS, ESRI等均使用此投影!
MapF = plot.MapFrame(Axes = None, BaseMapProj = 3857, Extent = None)

# 2.添加图层
MapL1 = MapF.AddLayer(WorldLayer)

请添加图片描述

2. 控制显示范围

from gma.map import plot

# 0. 打开 gma 内置的世界矢量
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)

# 1.初始化一个地图框,用于绘图
MapF = plot.MapFrame(Axes = None, BaseMapProj = 'WGS84', Extent = (-10, 30, 30, 60))

# 2.添加图层
MapL1 = MapF.AddLayer(WorldLayer)

请添加图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/188176.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于大数据的公共建筑能耗监测系统的应用探究

摘要:为了解决当前公共建筑能耗居高不下的突出问题,借助当前信息化技术手段,围绕公共建筑能耗监测系统中的大数据应用,从监测系统的总设计框架入手,分别就物联网中数据采集器设计方式、数据传输技术、数据库部署方式分…

【浪漫情人节】送你Python表白神器,祝天下有情人终成眷属

哈哈哈再过十几天就到了一年一度的情人节啦!如此浪漫的日子,小王决定用Python写一个简单的表白神器送给大家,祝天下有情人终成眷属! 目录 前言 一、Turtle小海龟 1. 基本函数 2. 漂浮爱心 二、Tkinter界面设计 1. 基本…

微信小程序015中医知识库百科科普系统

本系统为网上用户提供了一个在线浏览知识的平台。主要实现了用户登陆注册、在线浏览知识的功能,用户可以将自己的拥有的知识信息上传到中医药知识库系统中以供其他用户在线浏览并评论。同时实现了中医药知识库系统的后台管理功能,提供了管理员和操作员权…

06 Alibaba微服务组件Sentinel (1)

1、分布式系统遇到的问题 服务的可用性问题 服务的可用性场景 在一个高度服务化的系统中,我们实现的一个业务逻辑通常会依赖多个服务, 如图所示: 如果其中的下单服务不可用, 就会出现线程池里所有线程都因等待响应而被阻塞, 从而造成整个服务链路不可用, 进而导致…

深度解锁 CRUD 应用开发平台

全文 2400 字 阅读时间约 8 分钟 本文首发于码匠技术博客 目录 使用 CRUD 应用开发平台的好处 CRUD 应用开发平台的主要功能 如何使用 CRUD 应用开发平台? 如何自定义 CRUD 应用开发平台? 使用码匠开发的 CRUD 应用程序类型 关于码匠 CRUD 应用是具…

tomcat多实例优化及zabbix监控群集

tomcat简介Tomcat是Apache软件基金会(Apache Software Foundation)的Jakarta项目中的一个核心项目,由Apache,Sun和其他一些公司及个人共同开发而成。Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和…

LeetCode——2315. 统计星号

一、题目 给你一个字符串 s ,每两个连续竖线 ‘|’ 为 一对 。换言之,第一个和第二个 ‘|’ 为一对,第三个和第四个 ‘|’ 为一对,以此类推。 请你返回不在 竖线对之间,s 中 ‘*’ 的数目。 注意,每个竖…

python flask 操作 Redis,包含详细代码

使用 Flask 操作 Redis 可以通过安装 Redis 的 Python 库并在 Flask 中使用它来实现。 正式学习前,需要先确定 Redis 已安装并可正常运行 运行 redis-server.exe redis.windows.conf 启动 Redis 服务器 运行 redis-cli.exe ping 检查 Redis 服务器是否运行正常 运行…

IP地址扫描程序/扫描工具

随着许多组织采用自带设备 (BYOD) 等策略,IT 网络变得越来越复杂。随着越来越多的设备连接到网络,IP 地址扫描势在必行,以确保设备在连接到网络时不会遇到问题。IP 地址扫描器是 OpUtils 中的一个模块,是一…

Windows包管理工具winget

文章目录简介实操简介 在Win10或者Win11中默认安装了winget工具,可以直接在命令行中输入命令,如果有反应,说明已经安装。 >winget -v v1.4.10173输入winget可以查看命令列表 命令说明show显示包的相关信息install安装给定的程序包unins…

几何对象基本元素与表现

点与向量 点 (point) 表示空间中的位置,它有空间中的坐标,例如在三维空间中,点有 (x, y, z) 坐标。 向量 (vector) 是有方向的量,它可以表示在空间中的移动。向量可以通过两个点的差计算,它连接起始点和终止点。 结…

第3章:基于媒体查询生成PDF

图:pdfHTML C3F01 检查示例HTML文件 图3.1显示了一个HTML页面,介绍 South by South West,这是德克萨斯州奥斯汀的一项年度活动。该页面分布在三个浏览器窗口中;请参阅 sxsw.html 和 sxsw.css 以获取用于创建此页面的html和css代码。这个HTML页面的布局灵感来自 w3schools…

vite 运行项目报错 ‘axios/index.js‘ does not provide anexport named ‘default‘

报错信息 报错信息:The requested module ‘/node_modules/axios/index.js?v2866e624’ does not provide an export named ‘default’ 现象 使用 vite 打包工具开发时出现,生产环境正常 原因 原因在于 Vite 是完全依靠 ESM 原生能力的&#xff0c…

jspssm学生宿舍预订报修管理系统

目录 摘 要 1 Abstract 2 1 绪论 3 1.1 课题背景 4 1.2 课题研究现状 5 1.3 初步设计方法与实施方案 6 1.4 本文研究内容 7 2 系统开发环境 8 2.1 Java语言 9 2.2 JSP技术 9 2.3 B/S架构 9 2.4 Eclipse环境配置 9 2.5 MySQL数据库 9 3 …

springBean的作用域

前言:最近在进行springBean的作用域学习,并且学习了对应的例子。这里进行一下总结 一:Bean的作用域基础概念 如果想学习SpringBean的生命周期,那么就必须要学习Bean的作用域。因为不同的作用域的bean的生命周期不同 1:singleto…

基于VS2019的ceres solver配置

一、ceres solver介绍Ceres Solver 是一个开源的C库,用于建模和解决大型、复杂的优化问题。它可以用来解决有边界约束的非线性最小二乘法问题和一般无约束的优化问题。官网:http://www.ceres-solver.org/案例网址:http://www.ceres-solver.or…

【数据结构】各排序方法比较

文章目录一、时间性能二、空间性能三、排序方法的稳定性能四、关于排序方法的时间复杂度的下限一、时间性能 按照平均时间性能来分,有三类排序方法: 时间复杂度为 O(nlogn)的方法有: 快速排序、堆排序、归并排序,其中以快速排序最…

Cesium 常见错误集

解决cesium widgets.css is not exported from package 在版本1.9以上版本后,按照官方文档引入css 时 会报错:cesium widgets.css is not exported from package 解决方案: 1.node_modules里找到cesium的package.json文件,在exports里增加导出widgets.css [rml_read_mo…

华为HCIE学习之open stack开篇(笔记)

文章目录一、云计算和虚拟化的区别二、Openstack的作用三、Openstack部署方式四、Openstack内的一些概念1、租户2、镜像3、规格4、网络一、云计算和虚拟化的区别 云计算是一种服务模式,而虚拟化是一种具体的技术。 二、Openstack的作用 Openstack是一个云操作系统…

小程序开发(五)

上拉触底进行节流处理在data中定义isloading发起请求时完成时回调事件响应式判断自定义编译模式:》编译自动跳转生命周期:onlaunch 初始化完成 只执行一次onShow:切换到前台onHide:切换到后台app.js :onReady :渲染完成才可以修改…