[R-sig-Geo] function contourLines2SLDF

Roger Bivand Roger.Bivand at nhh.no
Mon Mar 26 09:27:14 CEST 2007


On Mon, 26 Mar 2007 Karl.Sommer at dpi.vic.gov.au wrote:

> Thanks for the hint Michael
> 
> there must have been a change in spelling the function name.  The maptool 
> function is spelt  "ContourLines2SLDF" rather than "contourLines2SLDF"  as 
> it was spelt before.  Anyway I am happy it is still there and it works. 

Yes, that's right. The function was in sp, and got moved to maptools in a
tidying up round, because sp is supposed to contain class definitions and
methods, especially subsetting and visualisation methods. The maptools
package is supposed to contain (some of) the tools for getting data into
and out of sp class objects, as well as stand-alone functions for reading
and writing shapefiles and Arc ASCII grid files. I should have been more
careful to use the Deprecated/Defunct mechanisms here, I'll try harder in
future!

Roger

> 
> Cheers
> 
> Karl 
> 
> 
> 
> 
> Michael Sumner <mdsumner at utas.edu.au> 
> Sent by: r-sig-geo-bounces at stat.math.ethz.ch
> 26/03/2007 10:43
> 
> To
> Karl.Sommer at dpi.vic.gov.au, r-sig-geo at stat.math.ethz.ch
> cc
> 
> Subject
> Re: [R-sig-Geo] function contourLines2SLDF
> 
> 
> 
> 
> 
> 
> Karl.Sommer at dpi.vic.gov.au wrote:
> > Hello list,
> >
> > I used to be able to apply the function contourLines2SLDF for the 
> > following operation on a SpatialGridDataFrame object. 
> >
> > 
> >> CL <- contourLines2SLDF(contourLines(as.image.SpatialGridDataFrame
> >> 
> > +       (as(ht.idw["var1.pred"],"SpatialGridDataFrame"))))
> >
> > 
> Gee I'd never noticed that function. I just checked and it's now in the 
> "maptools" package.
> 
> BTW, here's an example I used just the other day, in case that's helpful 
> to see what's going on. It depends on how your lines need to be 
> organized whether this will match your case.
> 
> Cheers, Mike.
> 
> "d" is a SpatialGridDataFrame
> "tab" is a SpatialPolygonsDataFrame (I'm looping over each polygon using 
> "kk", this is one iteration)
> 
> ## contour it
> l <- contourLines(as.image.SpatialGridDataFrame(d), levels = seq(0, 
> 2000, by = 10))
> 
> ## create empty list to hold lines
> ll <- vector("list", length(l))
> ## loop over list of contours to create Lines object
> for (i in 1:length(l)) ll[[i]] <- Lines(list(Line(cbind(l[[i]]$x, 
> l[[i]]$y))), as.character(i))
> 
> ## make those lines  Spatial, and fill out SpatialLinesDataFrame
> ll <- SpatialLines(ll, CRS(proj4string(d)))
> nm <- as.character(tab[kk,][["MAP_NAME"]])
> num <-as.character(tab[kk,][["MAP_NO"]])
> nn <- length(l)
> ll <- SpatialLinesDataFrame(ll, data.frame(level = unlist(lapply(l, 
> function(x) x$level)),
>                                 MAP_NAME = rep(nm, nn),
>                                 MAP_NO = rep(num, nn)))
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list