I have a rainfall time series for 15 hours in increments of 0.250s, I need to convert it from a .txt-file to a raster.

I've tried using r.mapcalc in GRASS, however, have not been successful. I've also tried creating a temporal data set in GRASS, but the layer creation always ends up empty. The output format needs to be a raster either asc or tif format, essentially a hyetograph in raster form. I don't mind if this is in either QGIS or GRASS. I've tried adding the layer extent to the txt file i.e. ncols, nrows and so on, cause the rainfall is uniform over a given location but I still haven't been successful.

The format is as follows:


Are there any other methods I could try out for the conversion?

  • Do these data have any spatial locations? If you are expecting just a hyetograph, then no GIS or raster are involved. You say "rainfall is uniform over a given location". What locations? Unless I misunderstood...
    – Micha
    Commented Oct 12, 2020 at 19:40
  • @Micha The location is a catchment in the UK Commented Oct 12, 2020 at 19:49
  • OK, but I'm still not clear what result you want. If your data is at 0.25 seconds, and covers 15 hours, then you have some 200,000 data points. Why not just plot rainfall along the time series, as a hyetograph? It's not clear to me what raster you are trying to produce.
    – Micha
    Commented Oct 13, 2020 at 10:39
  • I need a temporal raster for the time series, I need there to be 200,000 or some what data points, at the moment its just a csv in mm/hr format, I need to convert it to a temporal raster to fall over my modelling domain. The model I'm working with only accepts raster formats hence the requirement for the conversion. Commented Oct 13, 2020 at 14:13
  • Sorry to be difficult, but what is a "temporal raster". You have data points for 15 hours at a single point location. How would that become a raster? A raster in GIS, is a grid of usually thousands of X-Y locations, with a single value at each location. Here you have 200,000 values at a single location.
    – Micha
    Commented Oct 14, 2020 at 20:24

1 Answer 1


OK, bit by bit the details behind your question are unfolding. Itzi is an excellent flood simulation modeling program. To run it you must begin with an elevation raster, a DEM. Do you have a DEM raster covering your watershed?

Have you followed the steps in the Itzi wiki page?

Next, the example in those docs refers to a single rain map (with uniform precipitation over the watershed). The time steps in the tutorial simulation are 5 seconds, over a period of 2 hours (24 time steps). In your case, as I pointed out in the comments, you have a huge number of rainfall measurements: IIUC, you have rainrate every 1/4 second for 15 hours. So that's 4x60x60x15 = 216,000 total measurements (!). What do you intend to do with that data? Perhaps aggregate to hourly rainfall, then create 15 hourly raster maps, each with a uniform rain rate over your watershed. Then define a STRDS in GRASS from those 15 rainfall rasters and use that as input to Itzi...

If this is your plan, then:

  1. You need to be working in a projected LOCATION (required by Itzi), NOT long/lat
  2. You need a DEM as pointed out in the Itzi docs
  3. I assume you have a polygon of the watershed, already imported into GRASS

So the steps would be:

g.region -ap vect=<watershed_polygon>
# For each of the 15 hourly aggregated rainfall values:
r.mapcalc "rain_hr1 = <rainrall_at_hour1>"  # Note the space surrounding the '=' sign
r.mapcalc "rain_hr2 = <rainfall_at_hour2>"
# Create a STRDS
t.create type=strds temporaltype=relative output=rain_strds semantictype=mean title="Rain STRDS" description="Rain STRDS"
t.register -i type=raster input=rain_strds maps=`g.list raster pattern="rain_hr*" separator=comma` start="2020-10-10" increment="1 days"

Now you should have enough to get started with Itzi.

  • Thanks for this, yes I have all the required layer for ITZI, except the rainfall one I have a DEM, watershed polygon, all my boundary condition and friction layers. What I am struggling with was creating the individual raster maps at each time step of the rainfall, whether it is hour or seconds. Commented Oct 18, 2020 at 19:13
  • THANK YOU SO MUCH FOR THIS!! I've been stupidly trying to convert all values in a text file in a single raster instead of individual rasters. Commented Oct 18, 2020 at 19:43
  • Hello @Micha I have followed the steps above however, when registering I am met with the following error "Space time raster dataset <bc_dbase_30yr@PERMANENT> with relative time found, but no relative unit set for raster maps" I've tried setting the units which is then followed by "unit= can only be set for relative time" error. When I manage to get rid of these errors (by playing around) I am hit by another error "unable to update raster map <@PERMANENT>. The map does not exist", even though the raster map name is specified. Commented Oct 19, 2020 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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