R/rectangleSP_test.r

rectangleSP_test <- function (x0, y0, w, h) {
## Return SpatialPolygons (single) rectangle
  x = c(x0 + w/2, x0 - w/2, x0 - w/2, x0 + w/2)
  y = c(y0 + h/2, y0 + h/2, y0 - h/2, y0 - h/2)
  x = c(x, x[1]) ## force closure of polygon
  y = c(y, y[1]) ## force closure of polygon
  return(sp::SpatialPolygons(list(sp::Polygons(list(with(list(x = x, y = y),
                                                         sp::Polygon(cbind(x,y)))),1))) )
}

Try the SubgrPlots package in your browser

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

SubgrPlots documentation built on Jan. 29, 2020, 5:07 p.m.