New R user. I'm trying to create an observation window for a point pattern in R using a shapefile imported from ArcGIS. I've imported the shapefile and it is recognized by R as a feature class type:polygon. I need the xmin, xmax, ymin, ymax of the extent and that is all in order to specify these in creating the owin object. I can't seem to extract these values from the polygon. I know this is very basic but I can't put 2 and 2 together here.

  • 1
    object@bbox if its an sp* object
    – obrl_soil
    Nov 8, 2016 at 0:38

1 Answer 1


You can create a rectangle with the boundary box of your polygon. I use rgdal package to make a reproducible example, but you could use only raster package with shapefile() function instead of readOGR():


dsn <- system.file("vectors", package = "rgdal")[1]
polygon <- readOGR(dsn=dsn, layer="scot_BNG")

Creates an extent object using bbox and convert it to polygon:

e <- extent(polygon@bbox)

e <- as(e,"SpatialPolygons")

See the results:

plot(e, add= T)


  • see my "answer" above-- your solution worked-- thanks !
    – JMoore
    Nov 8, 2016 at 19:14
  • You do not need to call the bbox slot, the extent function does this for you. It is as simple as: e <- as(raster::extent(polygon), "SpatialPolygons") Nov 8, 2016 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.