helper function used to check that the input projection (passed as UTM zone, EPSG code, PROJ4 string or CRS object) is a valid string or CRS.

check_proj4string(projection, abort = FALSE, verbose = TRUE)

# S3 method for default
check_proj4string(projection, abort = FALSE,
  verbose = TRUE)

# S3 method for numeric
check_proj4string(projection, abort = FALSE,
  verbose = TRUE)

# S3 method for character
check_proj4string(projection, abort = FALSE,
  verbose = TRUE)

# S3 method for CRS
check_proj4string(projection, abort = FALSE,
  verbose = TRUE)

Arguments

projection

character or integer corresponding to the proj4string to be checked, the EPSG code or a UTM zone (e.g. "32N"); alternatively, a CRS object is accepted.

abort

logical if TRUE, the function aborts in case an invalid invalid projection is passed. Otherwise, the function returns "NA", Default: TRUE

Value

character proj4string of the object or file

Details

DETAILS

Examples

check_proj4string("+init=epsg:32632")
#> [1] "+init=epsg:32632 +proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
check_proj4string("32631")
#> [1] "+init=epsg:32631 +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
check_proj4string(32633)
#> [1] "+init=epsg:32633 +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
check_proj4string(30)
#> [1] "+init=epsg:32630 +proj=utm +zone=30 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
check_proj4string("example of invalid string")
#> Warning: check_proj4string --> Invalid projection detected, #> returning `NA`!
#> [1] NA
library(sp) check_proj4string(CRS("+init=epsg:32632"))
#> [1] "+init=epsg:32632 +proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
library(raster) in_rast <- read_rast(system.file("extdata/OLI_test", "oli_multi_1000_b2.tif", package = "sprawl.data")) check_proj4string(in_rast@crs)
#> [1] "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"