[R] Reminder: Question regarding reservoir volume and water level
javad bayat
j@b@y@t194 @end|ng |rom gm@||@com
Tue Apr 16 04:40:31 CEST 2024
On Wed, Apr 10, 2024 at 11:05 PM javad bayat <j.bayat194 using gmail.com> wrote:
> Dear all;
> Thank you for your reply.
> David has explained an interesting method.
> David I have DEM file of the region and I have extracted the xyz data from
> that.
> Also I can extract bathymetry data as xyz file.
> I have calculated the storage (volume) of reservoir at the current
> elevation.
> But the method I have used to calculate the volume is different from your
> method. I have crop DEM by the reservoir boundary and then calculate the
> volume.
> I would be more than happy if you please please explain more or write
> codes for me how to get volume at different elevation.
> And also about the following function, especially f(Storage).
>
> lm(Elevation~f(Storage)
> Sincerely
>
> On Tue, 9 Apr 2024, 21:26 David Stevens via R-help, <r-help using r-project.org>
> wrote:
>
>> Water engineer here. The standard approach is to 1) get the storage vs.
>> elevation data from the designers of the reservoir or, barring that, 2)
>> get the bathymetry data from USBR or state DWR, or, if available, get
>> the DEM data from USGS if the survey was done before the reservoir was
>> built or 3) get a boat+sonar with GPS +lots of time and survey the
>> bottom elevation yourself. Put the xyz data into ArcGIS and have it
>> create the bottom surface, then, with several elevations, integrate the
>> xyz data from Z to the bottom to find the storage. Plot the storage at
>> each water surface to get an idea of the shape and then use
>> lm(Elevation~f(Storage) where f(Storage) may be a cubic or quartic
>> polynomial. Then double the Storage and calculate Elevation. This type
>> of thing is done everyday by hydrologists.
>>
>> Good luck
>>
>> David K Stevens, PhD, PE, Professor
>> Civil and Environmental Engineering
>> Utah Water Research Laboratory
>> Utah State University
>> 8200 Old Main Hill
>> Logan, UT 84322-8200
>> david.stevens using usu.edu
>> (435) 797-3229 (office)
>>
>> On 4/9/2024 8:01 AM, peter dalgaard wrote:
>> > So, you know how to get volume for given water level.
>> >
>> > For the reverse problem, you get in trouble because of the nonlinearity
>> inherent in the dependence of surface area on the level.
>> >
>> > I don't think there is a simple solution to this, save for mapping out
>> the volume as a function of water level and solving equations for the water
>> level using (say) uniroot(). Which may actually suffice for practical
>> purposes.
>> >
>> > For small changes, finding the derivative of the relation is easy:
>> d(volume) = Area * d(level) and this can be used as an approximate relation
>> as long as the Area remains nearly constant.
>> >
>> > However generic questions like doubling the volume are impossible to
>> answer without knowledge of the reservoir shape. E.g. in a cylindrical
>> reservoir halving the water level also halves the volume, but in a conical
>> reservoir, halving the level leaves only 1/8 of the volume.
>> >
>> > -pd
>> >
>> >
>> >
>> >> On 8 Apr 2024, at 05:55 , javad bayat <j.bayat194 using gmail.com> wrote:
>> >>
>> >> Dear all;
>> >> Many thanks for your replies. This was not homework. I apologize.
>> >> Let me explain more.
>> >> There is a dam constructed in a valley with the highest elevation of
>> 1255
>> >> m. The area of its reservoir can be calculated by drawing a polygon
>> around
>> >> the water and it is known.
>> >> I have the Digital Elevation Model (DEM) of the region (reservoir and
>> its
>> >> surrounding area). I have calculated the volume of the current
>> reservoir
>> >> (7e6 m3) using the following codes.
>> >> library(raster)
>> >> library(terra)
>> >> library(exactextractr)
>> >> library(dplyr)
>> >> library(sf)
>> >> # Calculate volume for polygon
>> >> # Read the DEM raster file
>> >> r <- rast("E:/...DEM.tif")
>> >> # Read the polygon shapefile
>> >> p <- st_read("E:/...Dam.shp")
>> >>
>> >> r <- crop(r, extent(p))
>> >> r <- mask(r, p)
>> >>
>> >> # Extract the cells in each polygon and calculate the area of each cell
>> >> x <- exact_extract(r, p, coverage_area = TRUE)
>> >> # Extract polygon values as a dataframe
>> >> x1 = as.data.frame(x[1])
>> >> head(x1)
>> >> x1 = na.omit(x1)
>> >> # Calculate the height above the minimum elevation in the polygon
>> >> x1$Height = max(x1[,1]) - x1[,1]
>> >> # Calculate the volume of each cell
>> >> x1$Vol = x1[,2] * x1[,3]
>> >> sum(x1$Vol)
>> >> x2 = x1[,c(1,2,4)]
>> >> x2 = sort(x2,'value')
>> >> head(x2)
>> >> x3 <- aggregate(Vol ~ value, data = x2, FUN = sum)
>> >> x4 <- aggregate(coverage_area ~ value, data = x2, FUN = sum)
>> >> x5 = cbind(x3, Area = x4[,2])
>> >> library(dplyr)
>> >> x6 <- x5 %>%
>> >> mutate(V_sum = cumsum(Vol)) %>%
>> >> mutate(A_sum = cumsum(Area))
>> >> plot(x6$value~x6$V_sum)
>> >>
>> >> And I thought that it is possible to get the elevation for a specific
>> >> volume by linear model between elevation and volume, as follow:
>> >>
>> >> # Get a linear model between elevation and the volume
>> >> lm1 <- lm(value ~ V_sum, data = x6)
>> >> d <- data.frame(V_sum = 14e6) #
>> >> predict(lm1, newdata = d)
>> >>
>> >> But it is not possible through the LM.
>> >> Now I want to know what would be the water level in the reservoir if
>> the
>> >> reservoir volume doubled or we adding a known volume to it?
>> >> Also what would be the volume if the water level increases to 1250 m?
>> >>
>> >> I would be more than happy if you help me to do this.
>> >> Sincerely
>> >>
>> >> On Mon, Apr 8, 2024 at 12:23 AM <avi.e.gross using gmail.com> wrote:
>> >>
>> >>> John,
>> >>>
>> >>> Your reaction was what my original reaction was until I realized I
>> had to
>> >>> find out what a DEM file was and that contains enough of the kind of
>> >>> depth-dimension data you describe albeit what may be a very irregular
>> cross
>> >>> section to calculate for areas and thence volumes.
>> >>>
>> >>> If I read it correctly, this can be a very real-world problem worthy
>> of a
>> >>> solution, such as in places like California where they had a tad more
>> rain
>> >>> than usual and some reservoirs may overflow. Someone else provided
>> what
>> >>> sounds like a mathematical algorithm but my guess is what is needed
>> here is
>> >>> perhaps less analytic since there may be no trivial way to create
>> formulas
>> >>> and take integrals and so on, but simply an approximate way to
>> calculate
>> >>> incremental volumes for each horizontal "slice" and keep adding or
>> >>> subtracting them till you reach a target and then read off another
>> variable
>> >>> at that point such as depth.
>> >>>
>> >>> Some care must be taken as water level has to be relative to
>> something and
>> >>> many natural reservoirs have no unique bottom level. Some water may
>> also be
>> >>> stored underground and to the side and pour in if the level lowers or
>> can
>> >>> be
>> >>> used to escape if the level rises.
>> >>>
>> >>>
>> >>> -----Original Message-----
>> >>> From: R-help <r-help-bounces using r-project.org> On Behalf Of Sorkin, John
>> >>> Sent: Sunday, April 7, 2024 3:08 PM
>> >>> To: Rui Barradas <ruipbarradas using sapo.pt>; javad bayat <
>> j.bayat194 using gmail.com
>> >>>> ;
>> >>> R-help <R-help using r-project.org>
>> >>> Subject: Re: [R] Question regarding reservoir volume and water level
>> >>>
>> >>> Aside from the fact that the original question might well be a class
>> >>> exercise (or homework), the question is unanswerable given the data
>> given
>> >>> by
>> >>> the original poster. One needs to know the dimensions of the
>> reservoir,
>> >>> above and below the current waterline. Are the sides, above and below
>> the
>> >>> waterline smooth? Is the region currently above the waterline that can
>> >>> store
>> >>> water a mirror image of the region below the waterline? Is the region
>> above
>> >>> the reservoir include a flood plane? Will the additional water go
>> into the
>> >>> flood plane?
>> >>>
>> >>> The lack of required detail in the question posed by the original
>> poster
>> >>> suggests that there are strong assumptions, assumptions that typically
>> >>> would
>> >>> be made in a class-room example or exercise.
>> >>>
>> >>> John
>> >>>
>> >>> John David Sorkin M.D., Ph.D.
>> >>> Professor of Medicine, University of Maryland School of Medicine;
>> >>> Associate Director for Biostatistics and Informatics, Baltimore VA
>> Medical
>> >>> Center Geriatrics Research, Education, and Clinical Center;
>> >>> PI Biostatistics and Informatics Core, University of Maryland School
>> of
>> >>> Medicine Claude D. Pepper Older Americans Independence Center;
>> >>> Senior Statistician University of Maryland Center for Vascular
>> Research;
>> >>>
>> >>> Division of Gerontology and Paliative Care,
>> >>> 10 North Greene Street
>> >>> GRECC (BT/18/GR)
>> >>> Baltimore, MD 21201-1524
>> >>> Cell phone 443-418-5382
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> ________________________________________
>> >>> From: R-help <r-help-bounces using r-project.org> on behalf of Rui Barradas
>> >>> <ruipbarradas using sapo.pt>
>> >>> Sent: Sunday, April 7, 2024 10:53 AM
>> >>> To: javad bayat; R-help
>> >>> Subject: Re: [R] Question regarding reservoir volume and water level
>> >>>
>> >>> À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.
>> >>> http://www.avg.com/
>> >>>
>> >>> ______________________________________________
>> >>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >>> https://stat.ethz.ch/mailman/listinfo/r-help
>> >>> PLEASE do read the posting guide
>> >>> http://www.r-project.org/posting-guide.html
>> >>> and provide commented, minimal, self-contained, reproducible code.
>> >>>
>> >>> ______________________________________________
>> >>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >>> https://stat.ethz.ch/mailman/listinfo/r-help
>> >>> PLEASE do read the posting guide
>> >>> http://www.R-project.org/posting-guide.html
>> >>> and provide commented, minimal, self-contained, reproducible code.
>> >>>
>> >>>
>> >> --
>> >> Best Regards
>> >> Javad Bayat
>> >> M.Sc. Environment Engineering
>> >> Alternative Mail: bayat194 using yahoo.com
>> >>
>> >> [[alternative HTML version deleted]]
>> >>
>> >> ______________________________________________
>> >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
--
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