> Since, I cannot manually close all endings, I would like to do find a way to 
> create polygons from lines with open endings.
> Any suggestions ...?

If your lines are valid (i.e. correctly ordered pairs of coords), you
could probably just grab the first set of points in the list and add
that to the end... something like the following
(where line_layer is a SpatialLinesDataFrame):

> coords <- line_la...@lines[[1]]@lines[[...@coords
> coords <- rbind(coords,coords[1,])
> line_la...@lines[[1]]@lines[[...@coords <- coords

Note that it is simple to figure out how many features and geometries
(multipart features) to go through:

> length(line_la...@lines)
[1] 1032

> length(line_la...@lines[[1]]@Lines)
[1] 1

so then of course you can do this for all features in your line layer:

 tmp_lines <- line_la...@lines
 for (i in seq(length(tmp_lines))) {
     tmp_Lines <- tmp_lines[[...@lines
     for (j in seq(length(tmp_Lines))) {
         coords <- tmp_lines[[...@coords
         coords <- rbind(coords,coords[1,])
         line_la...@lines[[i]]@lines[[...@coords <- coords
     }
}

There are probably faster ways to do this using apply etc. but this
works, and is relatively readable...

Hope that helps,

Carson

-- 
Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation
National University of Ireland, Maynooth,
http://www.carsonfarmer.com/

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to