From 53c81736cc0485dc0d7259db0a98929d9283ce49 Mon Sep 17 00:00:00 2001 From: Lorena Abad Crespo Date: Mon, 2 Sep 2024 16:57:02 +0200 Subject: [PATCH 1/4] Parse to sf when attributes have a geometry column --- R/tidyverse.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/tidyverse.R b/R/tidyverse.R index 7e0a06b4..f26d20a0 100644 --- a/R/tidyverse.R +++ b/R/tidyverse.R @@ -1,6 +1,7 @@ # convert arrays to data.frame, in long form to_df = function(x) { - dplyr::as_tibble(lapply(x, function(y) structure(y, dim = NULL))) + out = dplyr::as_tibble(lapply(x, function(y) structure(y, dim = NULL))) + if(any(sapply(out, inherits, "sfc")) st_as_sf(out) else out } set_dim = function(x, d) { From 55312531f20f1feed2c26d344ce9f3c51ce57b1f Mon Sep 17 00:00:00 2001 From: Lorena Abad Crespo Date: Mon, 2 Sep 2024 17:01:42 +0200 Subject: [PATCH 2/4] Add sf:: to to_df() --- R/tidyverse.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tidyverse.R b/R/tidyverse.R index f26d20a0..01672d8e 100644 --- a/R/tidyverse.R +++ b/R/tidyverse.R @@ -1,7 +1,7 @@ # convert arrays to data.frame, in long form to_df = function(x) { out = dplyr::as_tibble(lapply(x, function(y) structure(y, dim = NULL))) - if(any(sapply(out, inherits, "sfc")) st_as_sf(out) else out + if(any(sapply(out, inherits, "sfc")) sf::st_as_sf(out) else out } set_dim = function(x, d) { From 204771508a91c6e15cb60e2c024b814f5216909e Mon Sep 17 00:00:00 2001 From: Lorena Abad Crespo Date: Mon, 2 Sep 2024 17:02:57 +0200 Subject: [PATCH 3/4] Update tidyverse.R --- R/tidyverse.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/tidyverse.R b/R/tidyverse.R index 01672d8e..abba9b91 100644 --- a/R/tidyverse.R +++ b/R/tidyverse.R @@ -1,7 +1,9 @@ # convert arrays to data.frame, in long form to_df = function(x) { out = dplyr::as_tibble(lapply(x, function(y) structure(y, dim = NULL))) - if(any(sapply(out, inherits, "sfc")) sf::st_as_sf(out) else out + if(any(sapply(out, inherits, "sfc")) { + sf::st_as_sf(out) + } else out } set_dim = function(x, d) { From 0d606c704c1134dc4f3677acb0b761be68203d25 Mon Sep 17 00:00:00 2001 From: Lorena Abad Crespo Date: Mon, 2 Sep 2024 17:03:48 +0200 Subject: [PATCH 4/4] Update tidyverse.R --- R/tidyverse.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/tidyverse.R b/R/tidyverse.R index abba9b91..c56f30f2 100644 --- a/R/tidyverse.R +++ b/R/tidyverse.R @@ -1,9 +1,7 @@ # convert arrays to data.frame, in long form to_df = function(x) { out = dplyr::as_tibble(lapply(x, function(y) structure(y, dim = NULL))) - if(any(sapply(out, inherits, "sfc")) { - sf::st_as_sf(out) - } else out + if(any(sapply(out, inherits, "sfc"))) sf::st_as_sf(out) else out } set_dim = function(x, d) {