create bbox R sp 1

create bbox R sp

# just 9 points on a grid:
x <- c(1,1,1,2,2,2,3,3,3)
y <- c(1,2,3,1,2,3,1,2,3)
xy <- cbind(x,y)
S <- SpatialPoints(xy)

Here is what the above code is Doing:
1. Create a vector of x coordinates
2. Create a vector of y coordinates
3. Combine the x and y coordinates into a matrix
4. Create a SpatialPoints object from the matrix
5. Get the bounding box of the SpatialPoints object

Similar Posts