[R] Question regarding reservoir volume and water level

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sun Apr 7 16:53:02 CEST 2024


Às 13:27 de 07/04/2024, javad bayat escreveu:
> Dear all;
> I have a question about the water level of a reservoir, when the volume
> changed or doubled.
> There is a DEM file with the highest elevation 1267 m. The lowest elevation
> is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
> Now I want to know what would be the water level if the volume rises to
> 1250 m? or what would be the water level if the volume doubled (14,000,000
> m3)?
> 
> Is there any way to write codes to do this in R?
> I would be more than happy if anyone could help me.
> Sincerely
> 
> 
> 
> 
> 
> 
> 
> 
Hello,

This is a simple rule of three.
If you know the level l the argument doesn't need to be named but if you 
know the volume v then it must be named.


water_level <- function(l, v, level = 1240, volume = 7e6) {
   if(missing(v)) {
     volume * l / level
   } else level * v / volume
}

lev <- 1250
vol <- 14e6

water_level(l = lev)
#> [1] 7056452
water_level(v = vol)
#> [1] 2480


Hope this helps,

Rui Barradas


-- 
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus.
www.avg.com



More information about the R-help mailing list