[R] Dampening the spline interpolation for contours

Dylan Beaudette debeaudette at ucdavis.edu
Mon Sep 13 23:06:43 CEST 2010


Although not an R solution, I would highly recommend the generic mapping tools 
GMT for this type of work.

http://gmt.soest.hawaii.edu/

Cheers,
Dylan

On Monday 13 September 2010, Craig Stanton wrote:
> Hello all,
> 	I'm very new to R and am having some trouble with the results of the
> interp function. I'm trying to produce a chart roughly akin to a weather
> map with natural looking filled contours over a large region of the south
> pacific. I've got a list of points and values to be mapped to those points
> and I use the interp function as follows:
>
> tab<-read.table("data.txt")
> library("akima")
> png("contour.png", width = 1000, height=500)
> colourRange<-colorRampPalette(c("#f9cd00","#f9cd00","#f9cd00","#f9cd00","#f
>fffff","#6afaff","#53a3ff","#53a3ff","#53a3ff"))
> filled.contour(interp(x=tab$V1,tab$V2, tab$V3, xo=seq(min(tab$V1),
> max(tab$V1),length=1000),yo=seq(min(tab$V2), max(tab$V2),length=500),
> linear = FALSE), xlim = range(160,190),ylim = range(-30,-10),
> zlim=c(-4,4),color.palette = colourRange   ) dev.off()
> rm(list = ls())
>
>
>
> I have added the "rm(list=ls())" on the end to try to reset the workspace
> because I've found that repeated running of this code can result in
> different output images. The main problem I am having is that though my
> values are all between -2.5 and 2.5 the interpolation gives me values well
> outside that range. Usually shown by colouring the areas white but
> confirmed by plotting a regular contour map instead of a filled contour.
> What I'd like to find out is if there is a way to dampen the cubic spline
> that is being used, or if there is an alternative to interp() that I should
> be looking at. Like I said before, I'm very new to R, so I may have missed
> something entirely obvious.
>
> Thanks in advance,
>     Craig
> ______________________________________________
> 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.



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341



More information about the R-help mailing list