Hi. I've create very simple example "cutting polygon by line c(0,5,10,5)" using by gpclib.
library(maptools) library(gpclib) x1<-t(structure(c(0,0,10,0,10,10,0,10,0,0),dim=c(2,5))) # simple square ### method using buffer min_buffer_dist <- 1e-10 # set minimum value x2<-t(structure(c(-1,5,11,5+min_buffer_dist,11,5-min_buffer_dist,-1,5),dim=c(2,4))) # buffered similar line as polygon # x2<-t(structure(c(-1,5,11,5,11,5,-1,5),dim=c(2,4))) # this line can't cut square, just vanished. plot(setdiff(as(x1,"gpc.poly"),as(x2,"gpc.poly"))) # plot result Regards. --- Roger Bivand <[EMAIL PROTECTED]> wrote: > On Tue, 30 Oct 2007, Agustin Lobo wrote: > > > Is it possible to divide a polygon by a line > > into 2 polygons? > > No, in general. All computational geometry ends up > in having to deal with > the type of polygon. A convex polygon is one thing, > and can be divided > into two parts, but a general polygon may be > concave, and the number of > parts does not have to be two - the line could cross > it multiple times. > The approach taken in the Rgshhs function in > maptools is to overlay a > rectangular box over the polygon(s), and see what > comes out, but quite > often it isn't two (or in that case a single part > within the rectangle). > > Roger > > > > > Agus > > > > -- > 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: [EMAIL PROTECTED] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo >
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo