View source: R/extract_spatial.R
feature_bbox | R Documentation |
Calculate the bounding box of the feature(s) in lat/lon, formatted for metadata field entry
feature_bbox(obj)
obj |
a spatial object from the |
a list with wbbox
, ebbox
, nbbox
, sbbox
fields
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.