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

Description Usage Arguments Value Examples

View source: R/extract_spatial.R

Description

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

Usage

1

Arguments

obj

a spatial object from the sp package

Value

a list with wbbox, ebbox, nbbox, sbbox fields

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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 Nov. 21, 2020, 7:44 p.m.