File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -454,7 +454,7 @@ addRasterImage_SpatRaster <- function(
454
454
) {
455
455
456
456
# terra 1.5-50 has terra::has.RGB()
457
- if (x @ ptr $ rgb ) {
457
+ if (has.RGB( x ) ) {
458
458
# RGB(A) channels to color table
459
459
x <- terra :: colorize(x , " col" )
460
460
} else if (terra :: nlyr(x ) > 1 ) {
Original file line number Diff line number Diff line change @@ -50,6 +50,21 @@ polygonData.SpatVector <- function(obj) {
50
50
51
51
52
52
# helpers -----------------------------------------------------------------
53
+ assure_crs_terra <- function (x ) {
54
+ prj <- crs(x , proj = TRUE )
55
+ if (is.lonlat(x , perhaps = TRUE , warn = FALSE )) {
56
+ if (! grepl(" +datum=WGS84" , prj , fixed = TRUE )) {
57
+ x <- project(x , " +proj=longlat +datum=WGS84" )
58
+ }
59
+ return (x )
60
+ }
61
+ # Don't have enough information to check
62
+ if (is.na(crs ) || (crs == " " )) {
63
+ warning(" SpatVector layer is not long-lat data" , call. = FALSE )
64
+ return (x )
65
+ }
66
+ project(x , " +proj=longlat +datum=WGS84" )
67
+ }
53
68
54
69
check_crs_terra <- function (x ) {
55
70
crs <- crs(x )
You can’t perform that action at this time.
0 commit comments