New answers tagged


I used a similar approach to the accepted answer in this post but was never really satisfied with it so I looked into alternatives and found the sf library. And using this library you can then write code like this: library(sf) # Shapefile from ABS: # map = read_sf("...


So if you have some extent objects from your shapefiles (ext1,ext2,ext3...) then you get full extent: spoly <-, sapply(c(ext1,ext2,ext3), FUN = function(x){as(x, 'SpatialPolygons')})) full_extent <- extent(bbox(spoly))


The raster::extent() can take SpatialObject as the input (not only (xmin, xmax, ymin, ymax)). If the input geometries are the same type, extent(union(cities, birds)) should work. However, as the cities are points and the birds are polygons in the provided example, we need a workaround (I would suggest rgeos::gUnion()). # The CRS have to be the same, but ...


Given a list of shapey objects: > shapes = list(cities, birds) Compute the list of extents of those shapey objects > shape_extents = lapply(shapes, raster::extent) and then call raster::merge on them to get the merged extent: >, shape_extents) class : Extent xmin : -165.27 xmax : 177.1302 ymin : -...

Top 50 recent answers are included