[R-sig-Geo] contourLines() to SpatialLineDataFrame

Ervan Rutishauser Ervan.Rutishauser at ecofog.gf
Tue Aug 4 15:26:51 CEST 2009


Dear all ,

I have a problem in converting some interpolated contourLines into SLDF, using the function ContourLines2SLDF. I tried with the example given in "Applied Spatial Data Analysis wit R", but for similar input data, the function returns a strange SLDF with my data... I am then unable to check for equality between first and last coordinates (suitable to create polygons)..
Does someone know what's wrong with my code??
Many thanks for your help!

library(maptools)
load("XXX/interpolated_den.Rdata")  ## the data is called DDD...
AA<-contourLines(DDD,levels=c(2))    ## I keep only the isolines of level 2
test<-ContourLines2SLDF(AA)                  ## library(maptools)   transforme les isolignes en SpatialLinesDataFrame

lns<-slot(test,"lines")           # as in the ASDAR p. 48
table(sapply(lns,function(x) length(slot(x,"Lines"))))

## return 28/1 rather that 1/28 -> lns is a list 1 object composed of 28 lines, rather than being a list of 28 object of 1 lines....
## thus I can't do the next step...

table(sapply(lignes, function(x) {
coord<-slot(slot(x,"Lines")[[1]],"coords")
identical(coord[1,],coord[nrow(coord),])}))


___________________________________________________________

Ervan Rutishauser
PhD student
CIRAD - UMR AMAP
BP 701
97387 Kourou Cedex
tel. 00594.594.32.92.96


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090804/88b99738/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: interpolated_den.Rdata
Type: application/octet-stream
Size: 2182 bytes
Desc: interpolated_den.Rdata
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090804/88b99738/attachment.obj>


More information about the R-sig-Geo mailing list