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. 

Cheers

Karl 




Michael Sumner <mdsumner@utas.edu.au> 
Sent by: r-sig-geo-bounces@stat.math.ethz.ch
26/03/2007 10:43

To
Karl.Sommer@dpi.vic.gov.au, r-sig-geo@stat.math.ethz.ch
cc

Subject
Re: [R-sig-Geo] function contourLines2SLDF






Karl.Sommer@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@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


	[[alternative HTML version deleted]]


