[R] Volume of polygon

javad bayat j@b@y@t194 @end|ng |rom gm@||@com
Wed Dec 6 05:13:34 CET 2023


 Dear all;
I am trying to calculate the volume of a polygon shapefile according to a
DEM raster. I have provided some codes at the end of this email.I dont know
if the codes are correct or not. Following this, I have another question
too.
I want to know if the volume of the reservoir rises or doubles, what would
be the elevation?
I would be more than happy if anyone could help me.
Sincerely

"
library(raster)
library(terra)
library(exactextractr)
library(dplyr)
library(sf)
r <- raster("Base.tif")
p <- shapefile("p.shp")
r <- crop(r, p)
r <- mask(r, p)
x <- exact_extract(r, p, coverage_area = TRUE)

x1 = as.data.frame(x[1])
head(x1)
x1 = na.omit(x1)

x1$Height = max(x1[,1]) - x1[,1]

x1$Vol = x1[,2] * x1[,3]

sum(x1$Vol)

"

-- 
Best Regards
Javad Bayat
M.Sc. Environment Engineering
Alternative Mail: bayat194 using yahoo.com

	[[alternative HTML version deleted]]



More information about the R-help mailing list