R/get_extent.R
get_extent.Rd
helper function used to retrieve the extent of a spatial object or file, and the associated proj4string
get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for default get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for sprawlext get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for Extent get_extent(in_object, proj4string, abort = FALSE) # S3 method for matrix get_extent(in_object, proj4string, abort = FALSE) # S3 method for character get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for Raster get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for sf get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for sfc get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for Spatial get_extent(in_object, proj4string = NULL, abort = FALSE) # S3 method for Spatial get_extent(in_object, proj4string = NULL, abort = FALSE)
in_object |
|
---|---|
proj4string | (optional) |
abort |
|
object of class sprawlext
return an object of class sprawlext
with two slots:
$extent: numeric (4)
extent of the object (xmin, ymin, xmax, ymax)
$proj4string: character
proj4string of the object
(if an extent can not be retrieved from in_object
)
library(raster) in_rast <- system.file("extdata/MODIS_test", "EVIts_test.tif", package = "sprawl.data") get_extent(in_rast)#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 12897004 1685995 12973683 1789545 #> #> Slot "proj4string": #> [1] "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs" #>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 12897004 1685995 12973683 1789545 #> #> Slot "proj4string": #> [1] "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs" #>in_vect <- system.file("extdata/shapes","lc_polys.shp", package = "sprawl.data") get_extent(in_vect)#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 120.17779 15.15353 121.33942 16.09343 #> #> Slot "proj4string": #> [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" #>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 120.17779 15.15353 121.33942 16.09343 #> #> Slot "proj4string": #> [1] "+proj=longlat +datum=WGS84 +no_defs" #>