Patrick Giraudoux
2004-Jan-31 09:50 UTC
[R] about contour - get contour coordinates - exclude area display
Dear all, I wonder about what could actually be possible with the function "contour": 1/ - the definition of contour lines is most often meaningless when the contours are drawn in areas where no real data points exist. It can however happen that irregular distributions lead to more or less irregular clouds of data points. Interpolations (eg: loess regression, GLM, etc...) are however generally made on regular grids passed to the function contour and thus can cover areas with no/few data points to some extent. It would be most useful to display the contours with a polygon argument allowing the exclusion of those areas (this is possible, for instance, with controur.krige of the package GeoR). Is there a way to exclude the display of contour lines out of polygon coordinates passed to the contour function (or another function in a package doing this) ? 2/ - it would also be most useful to get the contour lines coordinates (for instance, for importation in a GIS). Is there a way to get them? Thanks in advance for any hint, Patrick Giraudoux
Prof Brian Ripley
2004-Jan-31 14:23 UTC
[R] about contour - get contour coordinates - exclude area display
On Sat, 31 Jan 2004, Patrick Giraudoux wrote:> Dear all, > > I wonder about what could actually be possible with the function "contour": > > 1/ - the definition of contour lines is most often meaningless when the > contours are drawn in areas where no real data points exist. It can > however happen that irregular distributions lead to more or less > irregular clouds of data points. Interpolations (eg: loess regression, > GLM, etc...) are however generally made on regular grids passed to the > function contour and thus can cover areas with no/few data points to > some extent. It would be most useful to display the contours with a > polygon argument allowing the exclusion of those areas (this is > possible, for instance, with controur.krige of the package GeoR). IsThere is no function cont(r)our.krige in geoR. There is a function `contour.kriging', and that just calls contour, so you too can do whatever you think that does (and the help page does not tally with your description).> there a way to exclude the display of contour lines out of polygon > coordinates passed to the contour function (or another function in a > package doing this) ?Contour works on a rectangular grid. Set to NA those cells where you have no data, and you will not get contours there. Simple!> 2/ - it would also be most useful to get the contour lines coordinates > (for instance, for importation in a GIS). Is there a way to get them?Paul Murrell has fulfilled that request a while back. See the clines package on CRAN, or contourLines in the development version of R. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595