Re: [R] Smooth contour of a map

From: Pierre Bruyer <pbruyer_at_agaetis.fr>
Date: Tue, 17 May 2011 14:24:34 +0200

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


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. Received on Tue 17 May 2011 - 15:09:10 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 May 2011 - 15:15:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive