An S4 class to represent the extent of a spatial object, associated with its proj4string.

Slots

extent

numeric (4) extent of the object (xmin, ymin, xmax, ymax)

proj4string

character proj4string of the object

Examples

showClass("sprawlext")
#> Class "sprawlext" [package "sprawl"] #> #> Slots: #> #> Name: extent proj4string #> Class: numeric character
library(raster) in_rast <- system.file("extdata/MODIS_test", "EVIts_test.tif", package = "sprawl.data") ex_sprawlext <- get_extent(in_rast) # Convert sprawlext to Extent ex_extent <- as(ex_sprawlext, "Extent") ex_extent
#> class : Extent #> xmin : 12897004 #> xmax : 12973683 #> ymin : 1685995 #> ymax : 1789545
# Convert to bbox ex_bbox <- as(ex_sprawlext, "matrix") ex_bbox
#> min max #> x 12897004 12973683 #> y 1685995 1789545
# Convert to Spatial* objects as(ex_sprawlext, "SpatialPolygons")
#> class : SpatialPolygons #> features : 1 #> extent : 12897004, 12973683, 1685995, 1789545 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
as(ex_sprawlext, "SpatialPoints")
#> class : SpatialPoints #> features : 4 #> extent : 12897004, 12973683, 1685995, 1789545 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
as(ex_sprawlext, "SpatialLines")
#> class : SpatialLines #> features : 1 #> extent : 12897004, 12973683, 1685995, 1789545 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
# Convert to sf objects as(ex_sprawlext, "sfc_POLYGON")
#> Geometry set for 1 feature #> geometry type: POLYGON #> dimension: XY #> bbox: xmin: 12897000 ymin: 1685995 xmax: 12973680 ymax: 1789545 #> epsg (SRID): NA #> proj4string: +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
#> POLYGON ((12897004 1685995, 12897004 1789545, 1...
as(ex_sprawlext, "sfc_POINT")
#> Geometry set for 4 features #> geometry type: POINT #> dimension: XY #> bbox: xmin: 12897000 ymin: 1685995 xmax: 12973680 ymax: 1789545 #> epsg (SRID): NA #> proj4string: +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs
#> POINT (12897004 1685995)
#> POINT (12897004 1789545)
#> POINT (12973683 1789545)
#> POINT (12973683 1685995)
# Extract proj4string CRS ex_crs <- as(ex_sprawlext, "CRS") ex_crs
#> CRS arguments: #> +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 #> +units=m +no_defs
# Create sprawlext from extent and CRS get_extent(ex_extent, ex_crs)
#> 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" #>
# Create sprawlext from bbox and CRS get_extent(ex_bbox, ex_crs)
#> 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" #>