File: units.R

package info (click to toggle)
r-cran-sf 0.9-7%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,796 kB
  • sloc: cpp: 5,333; sh: 18; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
suppressPackageStartupMessages(library(sf))
suppressPackageStartupMessages(library(units))

if (utils::packageVersion("units") >= "0.5-0")
	units_options(auto_convert_names_to_symbols = FALSE)

ll = st_crs(4326)
sf:::crs_parameters(ll)$ud_unit

u = names(sf:::udunits_from_proj)

unrecognized = NULL
out = sapply(u, function(x) { 
  p4s = paste0("+proj=laea +units=", x)
  cat(x, ": ")
  ret = try(sf:::crs_parameters(st_crs(p4s))$ud_unit, silent = TRUE)
  if (! inherits(ret, "try-error"))
  	print(ret)
  else
    unrecognized = c(unrecognized, x)
})

if (length(unrecognized))
	print(paste("unrecognized units:", paste(unrecognized, collapse = ", "), ": older GDAL version?"))