feature_bbox: get the bounding box of the feature(s)

View source: R/extract_spatial.R

feature_bboxR Documentation

get the bounding box of the feature(s)

Description

Calculate the bounding box of the feature(s) in lat/lon, formatted for metadata field entry

Usage

feature_bbox(obj)

Arguments

obj

a spatial object from the sp package

Value

a list with wbbox, ebbox, nbbox, sbbox fields

Examples

library(sp)
Sr1 <- Polygon(cbind(c(-89,-89.5,-89,-88.5,-89),c(42,42,44,44,42)))
Srs1 <- Polygons(list(Sr1), "s1")
Sr2 <- Polygon(cbind(c(-105,-105.5,-106,-105.5,-105),c(31.4,32,34,34,32)))
Srs2 <- Polygons(list(Sr2), "s2")
p <- SpatialPolygons(list(Srs1, Srs2), proj4string=CRS("+init=epsg:4326 +proj=longlat 
+datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
p.df <- SpatialPolygonsDataFrame(Sr = p,
   data = data.frame(x=c(0,40), y=c(30,300), z=c(0,0), row.names=c('s1','s2')))
extract_feature(p.df)
## Not run: 
library(rgdal)
writeOGR(p.df, 'inst/extdata/example_shapefile/','example_shapefile',
   driver = 'ESRI Shapefile', overwrite_layer = TRUE)

## End(Not run)

USGS-R/meddle documentation built on April 28, 2024, 3:31 a.m.