[R] Smooth contour of a map
Pierre Bruyer
pbruyer at agaetis.fr
Tue May 17 14:24:34 CEST 2011
Thank you for your answer, but the function spline() (and a lot of other function in R) can't take in its parameters the original contour which are define by a vector, i.e. :
##creation of breaks for colors
i<-1
paliers <- c(-1.0E300)
while(i<=length(level[,1]))
{
paliers <- c(paliers,level[i,1])
i <- i+1
}
paliers <- c(paliers, 1.0E300)
Le 17 mai 2011 à 13:05, Duncan Murdoch a écrit :
> On 11-05-17 5:58 AM, Pierre Bruyer wrote:
>> I'm a French developer (so I am sorry if my english is not perfect). I have a problem to smooth the contours of a map. I have a dataset with 3 columns, x, y and z, where x and y are the coordinates of my points and z is evaluate to a qualitative elevation and his representation is a set of colors, which is define by levels.
>>
>> The problem is the curve of my contour is so linear, and I would like a more continuous contour. I use the function fitted.contour to draw my map.
>
> If you use a finer grid of x,y values you'll get shorter segments and they will look smoother.
>
> You might be able to use a smooth interpolator (e.g. spline()) rather than linear interpolation, but those occasionally do strange things e.g.
>
> x <- c(1:4, 5.9, 6:10)
> y <- c(1:4, 7, 6:10)
> plot(spline(x,y, n=200), type="l")
> points(x,y)
>
> where one point is out of line with the others, but the curve overcompensates in order to stay smooth.
>
> Duncan Murdoch
More information about the R-help
mailing list