ipeaGIT / geobr

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

[r-package] `read_country` with year=2019 or year=2020 returns states #350

Closed kguidonimartins closed 2 months ago

kguidonimartins commented 2 months ago
if (!require("geobr")) install.packages("geobr")
#> Loading required package: geobr
#> Loading required namespace: sf
if (!require("tidyverse")) install.packages("tidyverse")
#> Loading required package: tidyverse

packageVersion("geobr")
#> [1] '1.9.0'

years <-
  c( "1872", "1900", "1911", "1920", "1933", "1940", "1950", "1960", "1970",
     "1980", "1991", "2000", "2001", "2010", "2013", "2014", "2015", "2016",
     "2017", "2018", "2019", "2020")

years %>%
  purrr::map(~ geobr::read_country(year = .x)) %>%
  purrr::set_names(years)

#> $`1872`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.80132 ymin: -33.74912 xmax: -34.79313 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1900`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.80132 ymin: -33.74912 xmax: -34.79313 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1911`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -34.79313 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1920`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -34.79313 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1933`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: GEOMETRYCOLLECTION
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -34.79313 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 GEOMETRYCOLLECTION (MULTIPO...
#> 
#> $`1940`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -34.79313 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1950`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -32.39093 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1960`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -32.39093 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1970`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -32.39093 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1980`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -32.39093 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`1991`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99046 ymin: -33.74912 xmax: -32.39093 ymax: 5.271891
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.40975 -...
#> 
#> $`2000`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99094 ymin: -33.75158 xmax: -28.83563 ymax: 5.272156
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.56424 -...
#> 
#> $`2001`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99293 ymin: -33.75206 xmax: -28.83588 ymax: 5.271808
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.56731 -...
#> 
#> $`2010`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75208 xmax: -28.83594 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.46837 -...
#> 
#> $`2013`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75208 xmax: -28.83594 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.46837 -...
#> 
#> $`2014`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75208 xmax: -28.83594 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.46837 -...
#> 
#> $`2015`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75115 xmax: -28.83594 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.46837 -...
#> 
#> $`2016`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75115 xmax: -28.83594 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.46837 -...
#> 
#> $`2017`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75115 xmax: -28.83594 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.46837 -...
#> 
#> $`2018`
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75108 xmax: -28.84784 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#>                             geom
#> 1 MULTIPOLYGON (((-48.3898 -2...
#> 
#> $`2019`
#> Simple feature collection with 27 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75118 xmax: -28.84784 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#> First 10 features:
#>    code_state abbrev_state name_state code_region name_region
#> 1          11           RO   Rondônia           1       Norte
#> 2          12           AC       Acre           1       Norte
#> 3          13           AM   Amazônas           1       Norte
#> 4          14           RR    Roraima           1       Norte
#> 5          15           PA       Pará           1       Norte
#> 6          16           AP      Amapá           1       Norte
#> 7          17           TO  Tocantins           1       Norte
#> 8          21           MA   Maranhão           2    Nordeste
#> 9          22           PI      Piauí           2    Nordeste
#> 10         23           CE      Ceará           2    Nordeste
#>                              geom
#> 1  MULTIPOLYGON (((-65.3815 -1...
#> 2  MULTIPOLYGON (((-71.07772 -...
#> 3  MULTIPOLYGON (((-69.83766 -...
#> 4  MULTIPOLYGON (((-63.96008 2...
#> 5  MULTIPOLYGON (((-51.43248 -...
#> 6  MULTIPOLYGON (((-53.27918 2...
#> 7  MULTIPOLYGON (((-48.23163 -...
#> 8  MULTIPOLYGON (((-46.16128 -...
#> 9  MULTIPOLYGON (((-42.91539 -...
#> 10 MULTIPOLYGON (((-41.18292 -...
#> 
#> $`2020`
#> Simple feature collection with 27 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.99045 ymin: -33.75118 xmax: -28.84784 ymax: 5.271841
#> Geodetic CRS:  SIRGAS 2000
#> First 10 features:
#>    code_state abbrev_state name_state code_region name_region
#> 1          11           RO   Rondônia           1       Norte
#> 2          12           AC       Acre           1       Norte
#> 3          13           AM   Amazônas           1       Norte
#> 4          14           RR    Roraima           1       Norte
#> 5          15           PA       Pará           1       Norte
#> 6          16           AP      Amapá           1       Norte
#> 7          17           TO  Tocantins           1       Norte
#> 8          21           MA   Maranhão           2    Nordeste
#> 9          22           PI      Piauí           2    Nordeste
#> 10         23           CE      Ceará           2    Nordeste
#>                              geom
#> 1  MULTIPOLYGON (((-65.3815 -1...
#> 2  MULTIPOLYGON (((-71.07772 -...
#> 3  MULTIPOLYGON (((-69.83766 -...
#> 4  MULTIPOLYGON (((-63.96008 2...
#> 5  MULTIPOLYGON (((-51.43248 -...
#> 6  MULTIPOLYGON (((-53.27918 2...
#> 7  MULTIPOLYGON (((-48.23291 -...
#> 8  MULTIPOLYGON (((-46.16128 -...
#> 9  MULTIPOLYGON (((-42.91509 -...
#> 10 MULTIPOLYGON (((-41.18292 -...
rafapereirabr commented 2 months ago

Hi @kguidonimartins. What exactly is the issue you would like to report ?

kguidonimartins commented 2 months ago

Hi @rafapereirabr, sorry if I wasn't clear using the reprex results. The function read_country with parameters year = 2019 or year = 2020 returns states geometries (27) and not only one geometry for the entire country, as it is supposed to do. For all other years, the function returns only one geometry.

rafapereirabr commented 2 months ago

ah, nice catch! and thanks for clariflying! I'll fix this in the next few days.

rafapereirabr commented 2 months ago

problem fixed! Thanks again for the heads up, @kguidonimartins!