gc2gpc {AIGIS} | R Documentation |
Given a vector indicating minimum and maximum latitude and longitudes, creates a rectangular polygon of class gpc.poly
, which can then be used by other areal weighting functions. This is simply a very thin wrapper for as(...,\dQuote{gpc.poly}
, and use primarily as a convenient internal function.
gc2gpc(bounds)
bounds |
A vector of length four, who's entries are (in order): Minimum longitude, maximum longitude, minimum latitude, maximum latitude. |
A rectangular polygon object of class gpc.poly
.
Benjamin P. Bryant, bryant@prgs.edu
poly1 <- gc2gpc(c(0,1,0,1)) poly2 <- gc2gpc(c(.3,1.1,.25,1.02)) plot(poly1) plot(poly2,add=TRUE) plot(intersect(poly1,poly2), poly.args=list(col="blue"),add=TRUE) ## The function is currently defined as function(bounds){ minglon <- bounds[1] maxglon <- bounds[2] minglat <- bounds[3] maxglat <- bounds[4] gpoly <- cbind(c(minglon, maxglon, maxglon, minglon),c(minglat, minglat, maxglat, maxglat)) gpoly <- as(gpoly, "gpc.poly") return(gpoly) }