An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110825/fd2f372f/attachment.pl>
apply function to spatial grid data frame to calculate CTI
3 messages · Tom Vanwalleghem, Jean V Adams, Paul Hiemstra
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110825/10298464/attachment.pl>
On 08/25/2011 10:54 AM, Tom Vanwalleghem wrote:
Dear R helpers, I'm new to R and struggling with applying functions to a spatial grid data frame, called data for example.data has a variable named "slope" and "uparea" Basically, I need to calculate the tan(data$slope)Next, I need to divide data$uparea by data$slope and take the log() of that all In the basic examples I found how to make simple multiplications with a scalar likedata[["slope"]] = data[["slope"]]/2 # assigns new attribute I come from a background in GIS and fortran, so used to dealing with ordinary matrices, I'll admit I'm having trouble with understanding the format of this spatial grid data frame structureI've been trying different methods to index the data frame, or working with the function "lapply" but so far I can't seem to get my head wrapped around it. I appreciate any help.TomResearcher at University of CordobaSpain [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list 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.
I would most surely take a look at the raster package, this might also be more intuitive for you. In addition, there is a special mailing list for spatial tasks, r-sig-geo. These kinds of questions are more suitable for that mailing list. cheers, Paul
Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770