Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 @markusN:lists.osgeo.org/pipermail/grass-user/2013-February/067195.html –  Aaron Mar 8 '13 at 18:55
add comment

2 Answers 2

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
add comment

Your Answer

 
discard

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.