gc2gpc {AIGIS}R Documentation

A function to create a rectangular polygon from a vector of bounds

Description

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.

Usage

gc2gpc(bounds)

Arguments

bounds A vector of length four, who's entries are (in order): Minimum longitude, maximum longitude, minimum latitude, maximum latitude.

Value

A rectangular polygon object of class gpc.poly.

Author(s)

Benjamin P. Bryant, bryant@prgs.edu

See Also

cell.arealw

Examples


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)
     
  }

[Package AIGIS version 1.0 Index]