The input is checked whether its coordinate system is
present. If not, it is reprojected to the CRS specified in
crs_standard
.
Arguments
- input
Input object one of sf or terra::Spat* object
- crs_standard
character(1). A standard definition of coordinate reference system. Default is
"EPSG:4326"
Consult epsg.io for details of other CRS.
See also
Other Helper functions:
any_class_args()
,
clip_ras_ext()
,
clip_vec_ext()
,
crs_check()
,
datamod()
,
dep_check()
,
dep_switch()
,
ext2poly()
,
get_clip_ext()
,
is_bbox_within_reference()
,
is_within_ref()
,
par_def_q()
,
reproject_b2r()
,
vect_valid_repair()
Examples
library(sf)
library(terra)
options(sf_use_s2 = FALSE)
base_crs <- "EPSG:5070"
nc_path <- system.file("gpkg/nc.gpkg", package = "sf")
nc_sf <- sf::st_read(nc_path)
#> Reading layer `nc.gpkg' from data source
#> `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG'
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> Geodetic CRS: NAD27
reproject_std(nc_sf, base_crs)
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 1054293 ymin: 1348025 xmax: 1833499 ymax: 1689236
#> Projected CRS: NAD83 / Conus Albers
#> First 10 features:
#> AREA PERIMETER CNTY_ CNTY_ID NAME FIPS FIPSNO CRESS_ID BIR74 SID74
#> 1 0.114 1.442 1825 1825 Ashe 37009 37009 5 1091 1
#> 2 0.061 1.231 1827 1827 Alleghany 37005 37005 3 487 0
#> 3 0.143 1.630 1828 1828 Surry 37171 37171 86 3188 5
#> 4 0.070 2.968 1831 1831 Currituck 37053 37053 27 508 1
#> 5 0.153 2.206 1832 1832 Northampton 37131 37131 66 1421 9
#> 6 0.097 1.670 1833 1833 Hertford 37091 37091 46 1452 7
#> 7 0.062 1.547 1834 1834 Camden 37029 37029 15 286 0
#> 8 0.091 1.284 1835 1835 Gates 37073 37073 37 420 0
#> 9 0.118 1.421 1836 1836 Warren 37185 37185 93 968 4
#> 10 0.124 1.428 1837 1837 Stokes 37169 37169 85 1612 1
#> NWBIR74 BIR79 SID79 NWBIR79 geom
#> 1 10 1364 0 19 MULTIPOLYGON (((1288822 156...
#> 2 10 542 3 12 MULTIPOLYGON (((1307047 158...
#> 3 208 3616 6 260 MULTIPOLYGON (((1378070 157...
#> 4 123 830 2 145 MULTIPOLYGON (((1765395 166...
#> 5 1066 1606 3 1197 MULTIPOLYGON (((1661822 163...
#> 6 954 1838 5 1237 MULTIPOLYGON (((1703230 163...
#> 7 115 350 2 139 MULTIPOLYGON (((1765395 166...
#> 8 254 594 2 371 MULTIPOLYGON (((1716728 165...
#> 9 748 1190 2 844 MULTIPOLYGON (((1566041 161...
#> 10 160 2038 5 176 MULTIPOLYGON (((1415754 158...
nc_vect <- terra::vect(nc_sf)
reproject_std(nc_vect, base_crs)
#> class : SpatVector
#> geometry : polygons
#> dimensions : 100, 14 (geometries, attributes)
#> extent : 1054293, 1833499, 1348025, 1689236 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83 / Conus Albers (EPSG:5070)
#> 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