R包:ggspatial空间画图

news/2024/9/29 16:33:22/

在这里插入图片描述

ggplot2语法的空间图形画图

Spatial data plus the power of the ggplot2 framework means easier mapping.

加载R包

# install.packages("ggspatial")library(ggplot2)
library(ggspatial)
load_longlake_data()

Using layer_spatial() and annotation_spatial()

ggplot() +annotation_spatial(longlake_waterdf) +layer_spatial(longlake_depthdf, aes(col = DEPTH_M))

在这里插入图片描述

With raster layers, you can also use layer_spatial()

ggplot() + layer_spatial(longlake_depth_raster, aes(fill = after_stat(band1))) +scale_fill_viridis_c(na.value = NA)

在这里插入图片描述

Using north arrow and scalebar

ggplot() +annotation_spatial(longlake_waterdf) +layer_spatial(longlake_depthdf, aes(col = DEPTH_M)) +annotation_scale(location = "tl") +annotation_north_arrow(location = "br", which_north = "true")

在这里插入图片描述

Tile map layers

ggplot() +annotation_map_tile(type = "osm") +layer_spatial(longlake_depthdf, aes(col = DEPTH_M))

在这里插入图片描述

Data frames with coordinates

cities <- data.frame(x = c(-63.58595, 116.41214), y = c(44.64862, 40.19063), city = c("Halifax", "Beijing")
)ggplot(cities, aes(x, y)) +annotation_map_tile(type = "stamenwatercolor") +geom_spatial_point() +geom_spatial_label_repel(aes(label = city), box.padding = 1) +coord_sf(crs = 3995)

在这里插入图片描述

案例

library(ggplot2)
library(ggspatial)
load_longlake_data()ggplot() +# loads background map tiles from a tile sourceannotation_map_tile(zoomin = -1) +# annotation_spatial() layers don't train the scales, so data stays centralannotation_spatial(longlake_roadsdf, size = 2, col = "black") +annotation_spatial(longlake_roadsdf, size = 1.6, col = "white") +# raster layers train scales and get projected automaticallylayer_spatial(longlake_depth_raster, aes(colour = after_stat(band1))) +# make no data values transparentscale_fill_viridis_c(na.value = NA) +# layer_spatial trains the scaleslayer_spatial(longlake_depthdf, aes(fill = DEPTH_M)) +# spatial-aware automagic scale barannotation_scale(location = "tl") +# spatial-aware automagic north arrowannotation_north_arrow(location = "br", which_north = "true")

在这里插入图片描述

参考

  • https://paleolimbot.github.io/ggspatial/articles/ggspatial.html

http://www.ppmy.cn/news/1532004.html

相关文章

【赵渝强老师】Job控制器多工作队列的并行方式

Kubernetes Job是一次性任务的控制器。它控制Pod中的容器执行完成任务后不会再重启&#xff0c;并将容器的状态设置为“Completed”。如果Pod中的容器出现了异常终止的情况&#xff0c;Job控制器会根据设置的重启策略进行Pod的重启。如果因为Node节点的故障导致Pod无法正常运行…

计算机毕业设计 基于Python的音乐平台的设计与实现 Python+Django+Vue 前后端分离 附源码 讲解 文档

&#x1f34a;作者&#xff1a;计算机编程-吉哥 &#x1f34a;简介&#xff1a;专业从事JavaWeb程序开发&#xff0c;微信小程序开发&#xff0c;定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事&#xff0c;生活就是快乐的。 &#x1f34a;心愿&#xff1a;点…

AI 赋能大模型:从 ChatGPT 到国产大模型的角逐与发展契机

在当今科技飞速发展的时代&#xff0c;大模型作为人工智能领域的关键技术&#xff0c;正引发着深刻的变革。它们在自然语言处理、计算机视觉、语音识别等众多领域展现出了惊人的潜力&#xff0c;为各行各业带来了前所未有的机遇和挑战。本文将深入剖析大模型的技术原理、市场态…

ARM(Day 2)

一、作业 &#xff08;1&#xff09;汇编代码 .text.globl _start_start:mov r0, #0x5mov r1, #0x10比较r0,r1 是否相等 相等执行stop 不相等执行下一步比较&#xff08; r0 > r1 ?&#xff09;cmp r0, r1 比较实际在做减法 (YES NO )subhi r0, r0, r1 r0 > r1 …

OpenEuler虚拟机安装保姆级教程 | 附可视化界面

0x00 系统介绍 在 2019 年 7 月 19 日&#xff0c;华为宣布要在年底正式开源 openEuler 操作系统&#xff1b;在半年后的 12 月 31 日&#xff0c;华为正式开源了 openEuler 操作系统&#xff0c;邀请社区开发者共同来贡献。 一年后&#xff0c;截止到 2020 年12 月 25日&…

Leetcode 2320. 统计放置房子的方式数

原题链接&#xff1a;. - 力扣&#xff08;LeetCode&#xff09; 一条街道上共有 n * 2 个 地块 &#xff0c;街道的两侧各有 n 个地块。每一边的地块都按从 1 到 n 编号。每个地块上都可以放置一所房子。 现要求街道同一侧不能存在两所房子相邻的情况&#xff0c;请你计算并…

Spring Boot | 使用 `@Scheduled`: 定时任务的实现与优化

文章目录 引言基础介绍入参介绍及使用示例基础用法进阶用法并发控制动态调度复杂的Cron表达式外部化配置 最佳实践日志记录测试驱动开发监控与报警容错机制事务一致性 使用注意事项优缺点结论 引言 在现代软件开发中&#xff0c;定时任务是不可或缺的一部分&#xff0c;无论是…

戴尔笔记本电脑——重装系统

说明&#xff1a;我的电脑是戴尔G3笔记本电脑。 第一步&#xff1a;按照正常的装系统步骤&#xff0c;配置并进入U盘的PE系统 如果进入PE系统&#xff0c;一部分的硬盘找不到&#xff0c;解决办法&#xff1a;U盘PE系统——出现部分硬盘找不到的解决办法 第二步&#xff1a;磁…