如何在r中插入地图上的点

发布于 2025-02-04 11:15:02 字数 1100 浏览 5 评论 0原文

下面的代码生成了特定国家状态的地图。但是,我想在此生成的地图中插入某些属性的点。为此,我插入了属性的坐标。

Points_properties = structure (list(Properties=c(1,2,3,4,5,6), Latitude = c(-24.930473, -24.95575,-24.924161,-24.95579, -24.94557, -24.93267),
Longitude = c(-49.994889, -49.990162,-50.004343, -50.007371, -50.01542, -50.00702)), row.names=c(NA,6L), class="data.frame")

> Points_properties
  Properties  Latitude Longitude
1          1 -24.93047 -49.99489
2          2 -24.95575 -49.99016
3          3 -24.92416 -50.00434
4          4 -24.95579 -50.00737
5          5 -24.94557 -50.01542
6          6 -24.93267 -50.00702

下面可执行代码:

library(rgdal)

temp <- tempfile()
temp2 <- tempfile()
download.file("https://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2015/UFs/PR/pr_municipios.zip",temp)

unzip(zipfile = temp, exdir = temp2)
shp <- readOGR(temp2)

plot(shp)

The code below generates a map of a state of a specific country. However, I would like to insert the points of some properties in this generated map. For this, I inserted the coordinates of the properties.

Points_properties = structure (list(Properties=c(1,2,3,4,5,6), Latitude = c(-24.930473, -24.95575,-24.924161,-24.95579, -24.94557, -24.93267),
Longitude = c(-49.994889, -49.990162,-50.004343, -50.007371, -50.01542, -50.00702)), row.names=c(NA,6L), class="data.frame")

> Points_properties
  Properties  Latitude Longitude
1          1 -24.93047 -49.99489
2          2 -24.95575 -49.99016
3          3 -24.92416 -50.00434
4          4 -24.95579 -50.00737
5          5 -24.94557 -50.01542
6          6 -24.93267 -50.00702

Executable code below:

library(rgdal)

temp <- tempfile()
temp2 <- tempfile()
download.file("https://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2015/UFs/PR/pr_municipios.zip",temp)

unzip(zipfile = temp, exdir = temp2)
shp <- readOGR(temp2)

plot(shp)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞旧 2025-02-11 11:15:02

有许多库可以让您在图表中添加点。

在您的示例中,因为您的价值观彼此之间是如此亲密,因此绘制了一个点。

在base r:

plot(shp)

points(x = Points_properties$Longitude, y= Points_properties$Latitude, col = "red")

“在此处输入图像描述”

There are many libraries that allow you to add points to the graph.

Becuse your values are so close to each other in your example, it looks like one point is plotted.

In base R:

plot(shp)

points(x = Points_properties$Longitude, y= Points_properties$Latitude, col = "red")

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文