ipeaGIT / geobr

Easy access to official spatial data sets of Brazil in R and Python
https://ipeagit.github.io/geobr/
789 stars 118 forks source link

Duplicated census_tracts for 2022 data #364

Closed lgelape closed 1 month ago

lgelape commented 1 month ago

Hi,

As I was using some data from 2022's census tracts, I noticed that the read_census_tract() function seems to be extracting a duplicated sf collection.

The example below shows results from for the city of Belo Horizonte:

cidade2022 <- read_census_tract(
  year = 2022, code_tract = 3106200, simplified = F) 
nrow(cidade2022)
 # 10282

cidade2022_d <- read_census_tract(
  year = 2022, code_tract = 3106200, simplified = F) |> 
  distinct()
nrow(cidade2022_d)
# 5141

And here is some information on my R session:

> sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.5

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

other attached packages:
[1] sf_1.0-16   geobr_1.9.0 dplyr_1.1.4

loaded via a namespace (and not attached):
 [1] s2_1.1.6           utf8_1.2.4         generics_0.1.3     class_7.3-22      
 [5] lwgeom_0.2-14      KernSmooth_2.23-22 lattice_0.22-5     digest_0.6.35     
 [9] magrittr_2.0.3     grid_4.3.3         RColorBrewer_1.1-3 fastmap_1.1.1     
[13] tmap_3.3-4         e1071_1.7-14       leafsync_0.1.0     DBI_1.2.2         
[17] httr_1.4.7         fansi_1.0.6        crosstalk_1.2.1    viridisLite_0.4.2 
[21] XML_3.99-0.17      codetools_0.2-19   abind_1.4-5        cli_3.6.2         
[25] rlang_1.1.3        units_0.8-5        tmaptools_3.1-1    base64enc_0.1-3   
[29] tools_4.3.3        raster_3.6-26      parallel_4.3.3     curl_5.2.1        
[33] vctrs_0.6.5        R6_2.5.1           png_0.1-8          proxy_0.4-27      
[37] lifecycle_1.0.4    classInt_0.4-10    leaflet_2.2.2      htmlwidgets_1.6.4 
[41] pkgconfig_2.0.3    terra_1.7-71       pillar_1.9.0       data.table_1.15.4 
[45] glue_1.7.0         Rcpp_1.0.12        tibble_3.2.1       tidyselect_1.2.1  
[49] rstudioapi_0.16.0  dichromat_2.0-0.1  htmltools_0.5.8.1  leafem_0.2.3      
[53] wk_0.9.1           compiler_4.3.3     sp_2.1-3           stars_0.6-6   

Thanks for the great job creating and maintaining the package!

rafapereirabr commented 1 month ago

Hi @lgelape . Thanks for reporting this issue. You're correct. Some census tracts of the 2022 data set are duplicated . I'll have a look into this in the next few days.

rafapereirabr commented 1 month ago

Hi @lgelape. This should be fixed now. You only need to restart your R session. Please let me know if the problem persists.

rafapereirabr commented 1 month ago

Closing this issue for now. We can reopen it if the problem persists.