7.2 Querying and Setting CRS

7.2.1 For vector:

  • sf::st_crs : get the CRS

  • sf::st_crs("ESPG::4326")$input : how the user specified the CRS

  • sf::st_crs("ESPG:4326")$wkt : WKT, use cat()

sf::st_set_crs # is a convenient function
## function (x, value) 
## {
##     st_crs(x) = value
##     x
## }
## <bytecode: 0x564e48cba7c0>
## <environment: namespace:sf>

7.2.2 Raster:

terra::crs(my_rast) = "EPSG:26912"

Attention!: Setting does not alter coordinates values or geometries

You can also directly specify CRS with crs argument in sf::st_crs()/ sf::st_as_asf() and terra::rast()