R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("gpclib-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('gpclib') General Polygon Clipper Library for R (version 1.3 ) Type 'class ? gpc.poly' for help > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "gpc.poly-class" > > ### * gpc.poly-class > > flush(stderr()); flush(stdout()) > > ### Name: gpc.poly-class > ### Title: Class "gpc.poly" > ### Aliases: gpc.poly-class [,gpc.poly-method > ### append.poly,gpc.poly,gpc.poly-method area.poly,gpc.poly-method > ### coerce,matrix,gpc.poly-method coerce,data.frame,gpc.poly-method > ### coerce,gpc.poly,matrix-method coerce,gpc.poly,numeric-method > ### coerce,numeric,gpc.poly-method get.bbox,gpc.poly-method > ### get.pts,gpc.poly-method intersect,gpc.poly,gpc.poly-method > ### plot,gpc.poly-method scale.poly,gpc.poly-method > ### setdiff,gpc.poly,gpc.poly-method show,gpc.poly-method > ### union,gpc.poly,gpc.poly-method > ### Keywords: classes > > ### ** Examples > > ## Make some random polygons > set.seed(100) > a <- cbind(rnorm(100), rnorm(100)) > a <- a[chull(a), ] > > ## Convert `a' from matrix to "gpc.poly" > a <- as(a, "gpc.poly") > > b <- cbind(rnorm(100), rnorm(100)) > b <- as(b[chull(b), ], "gpc.poly") > > ## More complex polygons with an intersection > p1 <- read.polyfile(system.file("poly-ex/ex-poly1.txt", package = "gpclib")) > p2 <- read.polyfile(system.file("poly-ex/ex-poly2.txt", package = "gpclib")) > > ## Plot both polygons and highlight their intersection in red > plot(append.poly(p1, p2)) > plot(intersect(p1, p2), poly.args = list(col = 2), add = TRUE) > > ## Highlight the difference p1 \ p2 in green > plot(setdiff(p1, p2), poly.args = list(col = 3), add = TRUE) > > ## Highlight the difference p2 \ p1 in blue > plot(setdiff(p2, p1), poly.args = list(col = 4), add = TRUE) > > ## Plot the union of the two polygons > plot(union(p1, p2)) > > ## Take the non-intersect portions and create a new polygon > ## combining the two contours > p.comb <- append.poly(setdiff(p1, p2), setdiff(p2, p1)) > plot(p.comb, poly.args = list(col = 2, border = 0)) > > > ## Coerce from a matrix > x <- + structure(c(0.0934073560027759, 0.192713393476752, 0.410062456627342, + 0.470020818875781, 0.41380985426787, 0.271408743927828, 0.100902151283831, + 0.0465648854961832, 0.63981588032221, 0.772382048331416, + 0.753739930955121, 0.637744533947066, 0.455466052934407, + 0.335327963176065, 0.399539700805524, + 0.600460299194476), .Dim = c(8, 2)) > y <- + structure(c(0.404441360166551, 0.338861901457321, 0.301387925052047, + 0.404441360166551, 0.531852879944483, 0.60117973629424, 0.625537820957668, + 0.179976985040276, 0.341542002301496, 0.445109321058688, + 0.610817031070196, 0.596317606444189, 0.459608745684695, + 0.215189873417722), .Dim = c(7, 2)) > > x1 <- as(x, "gpc.poly") > y1 <- as(y, "gpc.poly") > > plot(append.poly(x1, y1)) > plot(intersect(x1, y1), poly.args = list(col = 2), add = TRUE) > > > > cleanEx(); ..nameEx <- "gpc.poly.nohole-class" > > ### * gpc.poly.nohole-class > > flush(stderr()); flush(stdout()) > > ### Name: gpc.poly.nohole-class > ### Title: Class "gpc.poly.nohole" > ### Aliases: gpc.poly.nohole-class coerce,numeric,gpc.poly.nohole-method > ### Keywords: classes > > ### ** Examples > > ## None > > > > cleanEx(); ..nameEx <- "new-generics" > > ### * new-generics > > flush(stderr()); flush(stdout()) > > ### Name: new-generics > ### Title: Generics/Methods for polygon objects > ### Aliases: new-generics append.poly append.poly-methods get.bbox > ### get.bbox-methods area.poly area.poly-methods get.pts get.pts-methods > ### scale.poly scale.poly-methods > ### Keywords: methods > > ### ** Examples > > holepoly <- read.polyfile(system.file("poly-ex/hole-poly.txt", package = + "gpclib"), nohole = FALSE) > area.poly(holepoly) [1] 8 > stopifnot(area.poly(holepoly) == 8) > > > > cleanEx(); ..nameEx <- "polyfile" > > ### * polyfile > > flush(stderr()); flush(stdout()) > > ### Name: polyfile > ### Title: Read/Write polygon data > ### Aliases: polyfile read.polyfile write.polyfile > ### Keywords: IO > > ### ** Examples > > ## None right now. > > > > ### *