From aa85a14334512b9fb85c86f0e10ea2c79a94b7dd Mon Sep 17 00:00:00 2001 From: Rob Williams Date: Sun, 21 Apr 2024 10:36:03 -0400 Subject: [PATCH] throw error if inputs have different CRS and CRS not supplied --- R/utils.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index c48ea78..2df2aa3 100644 --- a/R/utils.R +++ b/R/utils.R @@ -389,11 +389,16 @@ interpolate_pw <- function(from, call. = FALSE) } - # If CRS is given, transform all the objects + # If CRS is given, transform all the objects; error if mismatched CRS if (!is.null(crs)) { from <- sf::st_transform(from, crs) to <- sf::st_transform(to, crs) weights <- sf::st_transform(weights, crs) + } else { + unique_crs <- unique(c(sf::st_crs(from), sf::st_crs(to), sf::st_crs(weights))) + if (length(unique_crs) != 1) { + stop("All inputs must have the same CRS if CRS is not supplied") + } } # Make a from and a to ID