我想弄清楚如何計算河流橫截面面積。計算不同高度的橫截面面積
對於橫截面,我在5米寬的河流上每25釐米處都有深度。
x_profile <- seq(0, 500, 25)
y_profile = c(50, 73, 64, 59, 60, 64, 82, 78, 79, 76, 72, 68, 63, 65, 62, 61, 56, 50, 44, 39, 25)
如果有人對如何在r中完成這項工作有一些建議,非常感謝。
我想弄清楚如何計算河流橫截面面積。計算不同高度的橫截面面積
對於橫截面,我在5米寬的河流上每25釐米處都有深度。
x_profile <- seq(0, 500, 25)
y_profile = c(50, 73, 64, 59, 60, 64, 82, 78, 79, 76, 72, 68, 63, 65, 62, 61, 56, 50, 44, 39, 25)
如果有人對如何在r中完成這項工作有一些建議,非常感謝。
我們可以使用sf
包創建一個顯示橫截面的多邊形,然後計算面積。請注意,要創建多邊形,創建矩陣m
時,需要提供另外三個點c(0, 0)
,c(500, 0)
和c(0, 0)
。
x_profile <- seq(0, 500, 25)
y_profile <- c(50, 73, 64, 59, 60, 64, 82, 78, 79, 76, 72,
68, 63, 65, 62, 61, 56, 50, 44, 39, 25)
library(sf)
# Create matrix with coordinates
m <- matrix(c(0, x_profile, 500, 0, 0, -y_profile, 0, 0),
byrow = FALSE, ncol = 2)
# Create a polygon
poly <- st_polygon(list(m))
# View the polygon
plot(poly)
# Calcualte the area
st_area(poly)
31312.5
它看起來像一個整合的問題給我。我會通過使用線性插值和應用積分公式(最明顯的選擇是[梯形法則](https://en.wikipedia.org/wiki/Trapezoidal_rule))來處理它。該公式基本上簡化爲step * depth_i'的'i',其中'step = 0.5m'。 – tonytonov