Skip to contents

Align vector CRS to raster's

Usage

reproject_b2r(vector = NULL, raster = NULL)

Arguments

vector

sf/stars/SpatVector/SpatRaster object

raster

SpatRaster object

Value

Reprojected object in the same class as vector

Author

Insang Song

Examples

library(terra)
library(sf)
options(sf_use_s2 = FALSE)
ncpath <- system.file("gpkg/nc.gpkg", package = "sf")
elev <- system.file("ex/elev.tif", package = "terra")
nc <- terra::vect(ncpath)
elev <- terra::rast(elev)
reproject_b2r(nc, elev)
#>  class       : SpatVector 
#>  geometry    : polygons 
#>  dimensions  : 100, 14  (geometries, attributes)
#>  extent      : -84.32377, -75.45658, 33.88216, 36.58977  (xmin, xmax, ymin, ymax)
#>  coord. ref. : lon/lat WGS 84 (EPSG:4326) 
#>  names       :  AREA PERIMETER CNTY_ CNTY_ID      NAME  FIPS    FIPSNO CRESS_ID
#>  type        : <num>     <num> <num>   <num>     <chr> <chr>     <num>    <int>
#>  values      : 0.114     1.442  1825    1825      Ashe 37009 3.701e+04        5
#>                0.061     1.231  1827    1827 Alleghany 37005   3.7e+04        3
#>                0.143      1.63  1828    1828     Surry 37171 3.717e+04       86
#>  BIR74 SID74 (and 4 more)
#>  <num> <num>             
#>   1091     1             
#>    487     0             
#>   3188     5