Skip to content

Commit

Permalink
Merge pull request #567 from jayrobwilliams/interpolate_pw_crs
Browse files Browse the repository at this point in the history
Throw errorin interpolate_pw() if inputs have different CRS and CRS not supplied
  • Loading branch information
walkerke authored Jul 16, 2024
2 parents 52fc427 + aa85a14 commit 3600d0a
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 3600d0a

Please sign in to comment.