Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry error when summarise()ing Sichuan data #7

Open
pcdi opened this issue Jul 6, 2021 · 4 comments
Open

Geometry error when summarise()ing Sichuan data #7

pcdi opened this issue Jul 6, 2021 · 4 comments

Comments

@pcdi
Copy link

pcdi commented Jul 6, 2021

When trying Example 6 with Sichuan (province code 51), like so:

library(mapchina)
library(tidyverse)
library(sf)

df3 <- china %>%
  filter(Code_Province %in% "51")

df3 <- df3 %>%
  group_by(Name_Province) %>%
  summarise(geometry = st_union(geometry))

I get this error:

Error: Problem with `summarise()` column `geometry`.
ℹ `geometry = st_union(geometry)`.
x Evaluation error: Found 1 feature with invalid spherical geometry.
[159] Loop 0 is not valid: Edge 4 has duplicate vertex with edge 8.
ℹ The error occurred in group 1: Name_Province = "四川省".

My setup is as follows:

> sessionInfo()
R Under development (unstable) (2021-07-05 r80597)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8    LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                    LC_TIME=German_Germany.utf8    
system code page: 1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] sf_1.0-1        forcats_0.5.1   stringr_1.4.0   dplyr_1.0.7     purrr_0.3.4     readr_1.4.0     tidyr_1.1.3     tibble_3.1.2    ggplot2_3.3.5   tidyverse_1.3.1
[11] mapchina_0.1.0 

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.1   haven_2.4.1        colorspace_2.0-2   vctrs_0.3.8        generics_0.1.0     s2_1.0.6           utf8_1.2.1         rlang_0.4.11      
 [9] e1071_1.7-7        pillar_1.6.1       glue_1.4.2         withr_2.4.2        DBI_1.1.1          dbplyr_2.1.1       wk_0.4.1           modelr_0.1.8      
[17] readxl_1.3.1       lifecycle_1.0.0    munsell_0.5.0      gtable_0.3.0       cellranger_1.1.0   rvest_1.0.0        class_7.3-19       fansi_0.5.0       
[25] broom_0.7.8        Rcpp_1.0.6         KernSmooth_2.23-20 scales_1.1.1       backports_1.2.1    classInt_0.4-3     jsonlite_1.7.2     fs_1.5.0          
[33] hms_1.1.0          stringi_1.6.2      grid_4.2.0         cli_3.0.0          tools_4.2.0        magrittr_2.0.1     proxy_0.4-26       crayon_1.4.1      
[41] pkgconfig_2.0.3    ellipsis_0.3.2     xml2_1.3.2         reprex_2.0.0       lubridate_1.7.10   assertthat_0.2.1   httr_1.4.2         rstudioapi_0.13   
@Kevinlkc
Copy link

Same issue encountered.

@WeiZhang001-cugb
Copy link

Has anyone solved this challenge?

@LuffyLuffy
Copy link

sf_use_s2(FALSE)
add this line to the first line of your scripts.
mac is OK ,windows has problem.

@whkygl
Copy link

whkygl commented May 23, 2023

Same issue encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants