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)

Arguments

ext

object of class sprawlext, or any other object or filename from which a sprawlext object can be derived (see get_extent)

out_proj

character proj4string representing the desired projection for the output extent

in_proj

character (optional) proj4string representing the projection of projection (like extent or bbox). the input extent. It is needed only if ext is an object which does not include a

enlarge

logical If TRUE (default), the reprojected bounding box is the one which completely include the original one; if FALSE (faster), it is simply the one obtained by reprojecting the upper-left and the lower-right corners.

n_dens

numeric Densification ratio used in the case enlarge is TRUE. reprojected extent

verbose

logical If FALSE, suppress processing messages, Default: TRUE

Value

An object of class sprawlext representing the reprojected extent

Examples

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")
#> crop_rast --> Reprojecting extent of: in_sprawlext to: +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")
#> crop_rast --> Reprojecting extent of: in_file to: +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")
#> crop_rast --> Reprojecting extent of: in_rast to: +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)
#> crop_rast --> Reprojecting extent of: raster::extentin_rast to: +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" #>
reproj_extent(sp::bbox(in_rast), "+init=epsg:32651", in_proj=in_rast@crs)
#> crop_rast --> Reprojecting extent of: sp::bboxin_rast to: +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 without enlarging reproj_extent(in_sprawlext, "+init=epsg:32651", enlarge = FALSE)
#> crop_rast --> Reprojecting extent of: in_sprawlext to: +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" #>