如何绘制大量纬度/经度坐标的多边形并计算表面积?

问题描述 投票:0回答:3

我有以下数据:https://ufile.io/p9s0le6g ...由 485 个纬度/经度观测值组成。我最终想计算这个数字的表面积(以平方米或平方公里为单位)。我想用数据点(外部点)创建一个多边形,然后计算表面积。但是,我无法想出一个漂亮的多边形。 我的数据点作为坐标如下所示:

我想要一个看起来像这样(或类似)的多边形: 这是我尝试过的:

library(sp)
df <- read.csv('data.csv')
p = Polygon(df)
ps = Polygons(list(p),1)
sps = SpatialPolygons(list(ps))
plot(sps)

这会导致(显然不是一个漂亮的多边形): 我还尝试实现“从分布的点集创建多边形”的答案,但这对我来说只是一个矩形: 有人知道如何优化我的多边形以获得看起来像我的数据点的外部形状的图形以及如何计算该优化多边形的表面积吗?

r polygon r-sp
3个回答
5
投票
concaveman

sf
我们可以在您的一组点周围创建一个凹形外壳:

library(sf) library(concaveman) pts <- st_as_sf(df, coords=c('LONG','LAT'), crs=4326 ) conc <- concaveman(pts) conc %>% st_area() # 4010443 [m^2]

library(ggplot2)
ggplot() +
  geom_sf(data=pts, col = 'red', pch=3)  +
  geom_sf(data = conc, fill = NA)


4
投票

比如这个例子,建立在

sf::st_convex_hull


library(sf) library(tidyverse) points <- read_csv("data.csv") %>% st_as_sf(coords = c("LONG","LAT"), crs=4326) polygon <- st_union(points) %>% # unite the points to 1 object st_convex_hull() # calculate the convex hull # verify the results by drawing a map ggplot() + geom_sf(data = points, col = "red", size = 2, pch = 4) + geom_sf(data = polygon, col = "grey45", fill = NA) # as a bonus: area of the polygon area <- st_area(polygon) area


0
投票

我的 df 的纬度和经度格式为:23°38'34.4'' 和 72°27'38.5'',通常在 GIS 项目的实时数据集中找到,但这些坐标不被 coords=c 接受(经纬度),crs=4326)。 我尝试使用上述两种解决方案,但它不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.