accessory function to convert the extent of a spatial object to
a different projection. simple wrapper for the spTransform
function on
reproj_extent(ext, out_proj, in_proj = NULL, enlarge = TRUE, n_dens = 1000, verbose = TRUE)
ext | object of class |
---|---|
out_proj |
|
in_proj |
|
enlarge |
|
n_dens |
|
verbose |
|
An object of class sprawlext
representing the reprojected extent
library(raster) in_file <- system.file("extdata/MODIS_test", "EVIts_test.tif", package = "sprawl.data") in_rast <- raster::raster(in_file) in_sprawlext <- get_extent(in_rast) # Reproject a sprawlext reproj_extent(in_sprawlext, "+init=epsg:32651")#>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 195742.3 1677398.6 332519.7 1780655.5 #> #> Slot "proj4string": #> [1] "+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs" #># Reproject the extent of a file reproj_extent(in_file, "+init=epsg:32651")#>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 195742.3 1677398.6 332519.7 1780655.5 #> #> Slot "proj4string": #> [1] "+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs" #># Reproject the extent of a raster reproj_extent(in_rast, "+init=epsg:32651")#>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 195742.3 1677398.6 332519.7 1780655.5 #> #> Slot "proj4string": #> [1] "+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs" #># Reproject an extent or a bounding box (given the input projection) reproj_extent(raster::extent(in_rast), "+init=epsg:32651", in_proj=in_rast@crs)#>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 195742.3 1677398.6 332519.7 1780655.5 #> #> Slot "proj4string": #> [1] "+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs" #>#>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 195742.3 1677398.6 332519.7 1780655.5 #> #> Slot "proj4string": #> [1] "+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs" #># Reproject without enlarging reproj_extent(in_sprawlext, "+init=epsg:32651", enlarge = FALSE)#>#> An object of class "sprawlext" #> Slot "extent": #> xmin ymin xmax ymax #> 195742.3 1677398.6 332519.7 1780655.5 #> #> Slot "proj4string": #> [1] "+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs" #>