Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In GRASS GIS I have access to a table in PostgreSQL Database with this structure:

Table Name: rainfall_time_series

Columns: id | year | month | day | value_mm | x | y | gauge_code

Setting g.region to the Watershed limits, I need create for each day one interpolated raster, representing the rainfall. This times-series is very huge, has 17 years, my question is: is it possible to do this operation with a looping? it is probably easier in R, but I'm newbie in this software.

Thanks in advance

share|improve this question
Cross posted, as noted by – Aaron Mar 8 '13 at 18:55

The answer has been posted here:

share|improve this answer

Doing this in R would require a number of building blocks:

  • A function that extracts the unique days present in the database.
  • A function that extracts the data for one day from the database into a data.frame. You can then transform this to a SpatialPoints object (see sp package documentation.
  • A function that interpolates the data, and returns an interpolated grid for each day. This can be done using a host of interpolation methods in e.g. the automap/gstat package, the fields package, etc. For a more exhaustive list I refer to the CRAN Task view for Spatial data.

Once you have these blocks, the following pseudo code links them together:

unique_days = get_unique_days()
dat_list = lapply(unique_days, get_data_from_database) 
interpolated_maps = lapply(dat_list, interpolate_daily_data)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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