diff --git a/NEWS.md b/NEWS.md index c737a71..84d0134 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ + +* fix the `st_transformation` on `spatial_cubble_df` (#32) + # cubble 0.3.2 * fix the conversion between cubble and stars object (#30) diff --git a/R/dplyr.R b/R/dplyr.R index a163181..f6f5c6a 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -379,7 +379,10 @@ dplyr_row_slice.temporal_cubble_df <- function(data, i, ...){ dplyr_reconstruct.spatial_cubble_df <- function(data, template) { if (!inherits(data, "tbl_df")) data <- as_tibble(data) - if (is_sf(template)) data <- sf::st_as_sf(data, crs = sf::st_crs(template)) + if (is_sf(template)) { + new_crs <- data[[attr(template, "sf_column")]] |> sf::st_crs() + data <- sf::st_as_sf(data, crs = new_crs) + } new_spatial_cubble( data, key = key_vars(template),