Skip to content

Commit

Permalink
throw error if inputs have different CRS and CRS not supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrobwilliams committed Apr 21, 2024
1 parent aab2900 commit aa85a14
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa85a14

Please sign in to comment.