New answers tagged

2

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: # https://www.abs.gov.au/AUSSTATS/abs@.nsf/DetailsPage/1270.0.55.004July%202016?OpenDocument map = read_sf("...


2

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


2

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 ...


7

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: > do.call(raster::merge, shape_extents) class : Extent xmin : -165.27 xmax : 177.1302 ymin : -...


Top 50 recent answers are included