R/bbox2SP.R

Defines functions bbox2SP

Documented in bbox2SP

bbox2SP <- function(n, s, w ,e ,bbox=NA, proj4string=CRS("+init=epsg:4326")){
  if (all(!is.na(bbox), is.matrix(bbox), dim(bbox)==c(2,2))) {
      n<-bbox[2,2]
      s<-bbox[2,1]
      w<-bbox[1,1]
      e<-bbox[1,2]
    }
  box1 <- matrix(c(w, s, w, n, e, n, e, s, w, s), ncol=2, byrow=TRUE)
  box1 <- SpatialPolygons(list(Polygons(list(Polygon(box1)),ID=1)),
      proj4string=proj4string)
  box1
}

Try the rgeos package in your browser

Any scripts or data that you put into this service are public.

rgeos documentation built on July 26, 2023, 5:42 p.m.