1

I have information of maximum precipitation per grid cell for a certain area over 55 years, each year is a different matrix with the corresponding precipitation values. I know that I need to do the following steps:

-Convert the precipitation points into a raster

-clip the precipitation raster with the catchment area

-Get the maximum value of precipitation for 1 year from the clipped raster.

However, I don't wanna do this for each year, given that I have a total of 5 catchments so I will have to do this procedure 5*55=275 times.

Is there a way to program this operation in qgis/Grass and get a vector with the maximum precipitation per year for a given catchment?

  • How your data is organized? When you said a grid cell of max precipitation over 55 years I understand you already have a raster data with all the years. So you need to mask the raster with the catchment 5 times and get the report you want. Probably I am missing something or you do not have a raster but a set of location with max precipitation for 55 years. Please, clarify it. – Marco Nov 15 '17 at 10:19
  • @Marco My data is organized as a csv file with the coordinates (Longitude and latitude) and the following columns are the 55 years of data. I uploaded this file as a vector layer (points) into Qgis, therefore, the attribute table has the same columns as the csv file, and the catchment I have it as raster and shapefile. I could change my information into several shapefiles if that could make the programming simpler. I do not know how to upload pictures into the comments (I'm new) but I hope I have explained myself better this time. – Gina Torres Nov 15 '17 at 18:18
  • the best way to improve your question is editing it, a buttom just below your question on the left, you can upload images and it will help a three lines of your data or any example of it. – Marco Nov 16 '17 at 8:02
  • Your question is a very intersting one. I have not done what your are after, but i would like to be able to do it. From your comment I understand you have a set of gauge stations with coordinates and max precipitation (daily? hourly? other?) you might have elevation also. Then the question is how to converted in a surface. There are many methods (MLR, IDW, Kriging, RTS, etc). There is more than one example in the book "Open Source GIS: A GRASS Approach" in chapter 6.8 Spatial interpolation and approximation – Marco Nov 16 '17 at 8:24
  • I was thinking in your work and I wonder what means a raster with 55 years of max (daily?) rainfall. I doubt it is the right way to study or aggregate the information of each catchement area for this purpose. Max precipitation does not occur necesarly at the same time for all catchments, so you might end up taking a higher value than the acctual value for each catchement. In a more traditional hydrology way, I would do the statistical analisys for each gauge station and then produce maps for the return period of interst, let´s say 10, 20 and 50 years of return period. Isn't easier also? – Marco Nov 16 '17 at 13:46
1

Here is a translation of the steps in your question to GRASS commands. Without knowing how your data are structured, I'll make some assumptions. Lets say the precipitation data are CSV files with three columns, x_coord, y_coord and precip. Each file precip file has the year in its file name, like "precip_2010.csv". And I'll assume you have already imported your catchment areas into GRASS as polygon vector named "catch". Then:

# Loop thru all year data columns in CSV files
for col in `seq 3 55`; do
  new_precip="yr_"$col
# (Note: You could add some trickery here 
# to calculate the actual year from the column number)
# Read into GRASS using the r.in.xyz module
# set 'z' parameter to the column number
  r.in.xyz input=$f output=new_precip method=sum separator=comma z=$col
# Don't forget to set the computational region
  g.region -p rast=new_precip
# Get statistics for this year into the catchments
# Here are only three statistics, but there are more available
  v.rast.stats map=catch rast=new_precip method=minimum,maximum,average column_prefix="stats_"$col
# Remove raster
  g.remove -f rast name=new_precip
done

After the script completes, the catchments vector will have three new columns for each of the years: minimum, maximum and average precipitation for each catchment for each year (165 new columns). So there would be, i.e. columns named "stats_2010_minimum, stats_2010_maximum, stats_2010_average" and so on for all years. You will also have all the precipitation rasters for all years.

The above is suited for running in a bash terminal (linux). On windows, it would have to be changed to use the equivalent windows commands.

Does that help?

  • Sorry for not explaining how the data was structured it is organized as a csv file with the coordinates (Longitude and latitude) and the following columns are the 55 years of data. I uploaded this file as a vector layer (points) into Qgis, therefore, the attribute table has the same columns as the csv file, and the catchment is as raster and shapefile. Is there a way to not store the rasters? And just get the final vector? – Gina Torres Nov 15 '17 at 18:23
  • I have made some edits to the answer above based on your comment. – Micha Nov 17 '17 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.