Skip to content

A Package for Accessing the Municipal-level Data of the Instituto Brasileiro de Geografia e Estatistica (Brazilian Institute of Geography and Statistics)

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

RobertMyles/ibge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ibgeR

ibgeR is a work in progress. The idea is to download and make available (in a tidy format) the data from the IBGE Cidades project.

As this is A WIP, contributions are welcome. GET requests for this are quite straightforward.

Proof of concept:

library(dplyr) # pipe
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

x <- httr::GET("https://servicodados.ibge.gov.br/api/v1/biblioteca?aspas=3&codmun=280030") %>% 
  xml2::read_html() %>% 
  rvest::html_text() %>% 
  jsonlite::fromJSON()

library(purrr)

df <- tibble(
  municipio = map_chr(x, "MUNICIPIO", .null = NA_character_), 
  estado = map_chr(x, "ESTADO", .null = NA_character_),
  history = map_chr(x, "HISTORICO", .null = NA_character_),
  source_history = map_chr(x, "HISTORICO_FONTE", .null = NA_character_),
  administrative_history = map_chr(x, "FORMACAO_ADMINISTRATIVA", .null = NA_character_),
  locals = map_chr(x, "GENTILICO", .null = NA_character_)
  ) %>% 
  tidyr::separate(estado, into = c("state", "uf"), sep = " - ")

df
#> # A tibble: 1 x 7
#>   municipio state  uf    history  source_history  administrative_h… locals
#>   <chr>     <chr>  <chr> <chr>    <chr>           <chr>             <chr> 
#> 1 Aracaju   Sergi… SE    "Logo a… Aracaju (SE). … "Distrito criado… araca…

There is a dataset of municipio codes, names and UFs included.

data("ibge_codes")
head(ibge_codes)
#> # A tibble: 6 x 4
#>     codes municipio            uf    municipio_ascii     
#>     <int> <chr>                <chr> <chr>               
#> 1 1100015 Alta Floresta DOeste RO    Alta Floresta DOeste
#> 2 1100023 Ariquemes            RO    Ariquemes           
#> 3 1100031 Cabixi               RO    Cabixi              
#> 4 1100049 Cacoal               RO    Cacoal              
#> 5 1100056 Cerejeiras           RO    Cerejeiras          
#> 6 1100064 Colorado do Oeste    RO    Colorado do Oeste

About

A Package for Accessing the Municipal-level Data of the Instituto Brasileiro de Geografia e Estatistica (Brazilian Institute of Geography and Statistics)

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages