Created
March 29, 2023 16:47
-
-
Save kguidonimartins/74a272b6fd42be6d5429d43585578cb5 to your computer and use it in GitHub Desktop.
Obtenção das coordenadas geográficas da sede das capitais do Brasil via `{geobr}`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## -*- mode: ess-r; coding: utf-8-*- | |
## scratch-mode: ess-r-mode | |
## created-at: 20230329-111607 | |
### Obtenção das coordenadas geográficas da sede das capitais do Brasil via `{geobr}` | |
if (!require("tidyverse")) install.packages("tidyverse") | |
if (!require("sf")) install.packages("sf") | |
if (!require("geobr")) install.packages("geobr") | |
options( | |
tibble.print_min = 30, | |
tibble.print_max = 30 | |
) | |
capitais_uf <- | |
tibble::tribble( | |
~codigo_ibge, ~capital, ~uf, | |
2800308L , "Aracaju", "SE", | |
3106200L , "Belo Horizonte", "MG", | |
1501402L , "Belém", "PA", | |
1400100L , "Boa Vista", "RR", | |
5300108L , "Brasília", "DF", | |
5002704L , "Campo Grande", "MS", | |
5103403L , "Cuiabá", "MT", | |
4106902L , "Curitiba", "PR", | |
4205407L , "Florianópolis", "SC", | |
2304400L , "Fortaleza", "CE", | |
5208707L , "Goiânia", "GO", | |
2507507L , "João Pessoa", "PB", | |
1600303L , "Macapá", "AP", | |
2704302L , "Maceió", "AL", | |
1302603L , "Manaus", "AM", | |
2408102L , "Natal", "RN", | |
1721000L , "Palmas", "TO", | |
4314902L , "Porto Alegre", "RS", | |
1100205L , "Porto Velho", "RO", | |
2611606L , "Recife", "PE", | |
1200401L , "Rio Branco", "AC", | |
3304557L , "Rio De Janeiro", "RJ", | |
2927408L , "Salvador", "BA", | |
2111300L , "São Luís", "MA", | |
3550308L , "São Paulo", "SP", | |
2211001L , "Teresina", "PI", | |
3205309L , "Vitória", "ES" | |
) | |
sedes_capitais_sf <- | |
geobr::read_municipal_seat(year = 2010) %>% | |
dplyr::filter(code_muni %in% capitais_uf$codigo_ibge) | |
sedes_capitais_df <- | |
sedes_capitais_sf %>% | |
dplyr::mutate( | |
longitude = sf::st_coordinates(.)[, "X"], | |
latitude = sf::st_coordinates(.)[, "Y"], | |
.before = geom | |
) %>% | |
sf::st_drop_geometry() %>% | |
dplyr::arrange(name_muni) %>% | |
dplyr::as_tibble() | |
sedes_capitais_sf %>% | |
sf::st_write("./sedes-capitais-geom.geojson") | |
sedes_capitais_df %>% | |
readr::write_csv("./sedes-capitais-coords.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code_muni | name_muni | code_state | abbrev_state | code_region | name_region | year | longitude | latitude | |
---|---|---|---|---|---|---|---|---|---|
2800308 | Aracaju | 28 | SE | 2 | Nordeste | 2010 | -37.048212639512236 | -10.907215797883499 | |
3106200 | Belo Horizonte | 31 | MG | 3 | Sudeste | 2010 | -43.92645317353045 | -19.93752429377505 | |
1501402 | Belém | 15 | PA | 1 | Norte | 2010 | -48.48782568748754 | -1.459845 | |
1400100 | Boa Vista | 14 | RR | 1 | Norte | 2010 | -60.67053267296504 | 2.81668191910439 | |
5300108 | Brasília | 53 | DF | 5 | Centro Oeste | 2010 | -47.88790547803133 | -15.794087361890998 | |
5002704 | Campo Grande | 50 | MS | 5 | Centro Oeste | 2010 | -54.61574356645883 | -20.4580299878639 | |
5103403 | Cuiabá | 51 | MT | 5 | Centro Oeste | 2010 | -56.07325203819113 | -15.569989013120598 | |
4106902 | Curitiba | 41 | PR | 4 | Sul | 2010 | -49.271847885077406 | -25.432955999999997 | |
4205407 | Florianópolis | 42 | SC | 4 | Sul | 2010 | -48.54763737819332 | -27.58779554854995 | |
2304400 | Fortaleza | 23 | CE | 2 | Nordeste | 2010 | -38.589927555043175 | -3.723805035 | |
5208707 | Goiânia | 52 | GO | 5 | Centro Oeste | 2010 | -49.25581427581575 | -16.673309773838945 | |
2507507 | João Pessoa | 25 | PB | 2 | Nordeste | 2010 | -34.87338481353855 | -7.14938202 | |
1600303 | Macapá | 16 | AP | 1 | Norte | 2010 | -51.05740545703594 | 0.03895101 | |
2704302 | Maceió | 27 | AL | 2 | Nordeste | 2010 | -35.701629913489484 | -9.66082215163114 | |
1302603 | Manaus | 13 | AM | 1 | Norte | 2010 | -60.02333518106102 | -3.134691491201945 | |
2408102 | Natal | 24 | RN | 2 | Nordeste | 2010 | -35.2522547280543 | -5.750898537612059 | |
1721000 | Palmas | 17 | TO | 1 | Norte | 2010 | -48.35104370824618 | -10.163253326792749 | |
4314902 | Porto Alegre | 43 | RS | 4 | Sul | 2010 | -51.228660463702326 | -30.030036774766394 | |
1100205 | Porto Velho | 11 | RO | 1 | Norte | 2010 | -63.83144565436112 | -8.768891790000001 | |
2611606 | Recife | 26 | PE | 2 | Nordeste | 2010 | -34.88894194457771 | -8.062762483052406 | |
1200401 | Rio Branco | 12 | AC | 1 | Norte | 2010 | -67.81052870042349 | -9.97829875272498 | |
3304557 | Rio De Janeiro | 33 | RJ | 3 | Sudeste | 2010 | -43.22787512499518 | -22.87665211818645 | |
2927408 | Salvador | 29 | BA | 2 | Nordeste | 2010 | -38.488061484007844 | -13.01477191153275 | |
2111300 | São Luís | 21 | MA | 2 | Nordeste | 2010 | -44.29791856424437 | -2.5318859850833895 | |
3550308 | São Paulo | 35 | SP | 3 | Sudeste | 2010 | -46.57038318211274 | -23.567386499999998 | |
2211001 | Teresina | 22 | PI | 2 | Nordeste | 2010 | -42.80527045822334 | -5.0863419523217 | |
3205309 | Vitória | 32 | ES | 3 | Sudeste | 2010 | -40.322208726726615 | -20.3201537928533 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "FeatureCollection", | |
"name": "sedes-capitais-geom", | |
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4674" } }, | |
"features": [ | |
{ "type": "Feature", "properties": { "code_muni": 1100205.0, "name_muni": "Porto Velho", "code_state": "11", "abbrev_state": "RO", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -63.831445654361119, -8.76889179 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 1200401.0, "name_muni": "Rio Branco", "code_state": "12", "abbrev_state": "AC", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -67.81052870042349, -9.97829875272498 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 1302603.0, "name_muni": "Manaus", "code_state": "13", "abbrev_state": "AM", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -60.023335181061022, -3.134691491201945 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 1400100.0, "name_muni": "Boa Vista", "code_state": "14", "abbrev_state": "RR", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -60.670532672965038, 2.81668191910439 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 1501402.0, "name_muni": "Belém", "code_state": "15", "abbrev_state": "PA", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -48.487825687487543, -1.459845 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 1600303.0, "name_muni": "Macapá", "code_state": "16", "abbrev_state": "AP", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -51.057405457035941, 0.03895101 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 1721000.0, "name_muni": "Palmas", "code_state": "17", "abbrev_state": "TO", "code_region": "1", "name_region": "Norte", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -48.351043708246181, -10.163253326792749 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2111300.0, "name_muni": "São Luís", "code_state": "21", "abbrev_state": "MA", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -44.29791856424437, -2.531885985083389 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2211001.0, "name_muni": "Teresina", "code_state": "22", "abbrev_state": "PI", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -42.80527045822334, -5.0863419523217 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2304400.0, "name_muni": "Fortaleza", "code_state": "23", "abbrev_state": "CE", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -38.589927555043175, -3.723805035 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2408102.0, "name_muni": "Natal", "code_state": "24", "abbrev_state": "RN", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -35.252254728054297, -5.750898537612059 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2507507.0, "name_muni": "João Pessoa", "code_state": "25", "abbrev_state": "PB", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -34.87338481353855, -7.14938202 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2611606.0, "name_muni": "Recife", "code_state": "26", "abbrev_state": "PE", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -34.888941944577709, -8.062762483052406 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2704302.0, "name_muni": "Maceió", "code_state": "27", "abbrev_state": "AL", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -35.701629913489484, -9.660822151631139 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2800308.0, "name_muni": "Aracaju", "code_state": "28", "abbrev_state": "SE", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -37.048212639512236, -10.907215797883499 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 2927408.0, "name_muni": "Salvador", "code_state": "29", "abbrev_state": "BA", "code_region": "2", "name_region": "Nordeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -38.488061484007844, -13.014771911532749 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 3106200.0, "name_muni": "Belo Horizonte", "code_state": "31", "abbrev_state": "MG", "code_region": "3", "name_region": "Sudeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -43.926453173530447, -19.937524293775049 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 3205309.0, "name_muni": "Vitória", "code_state": "32", "abbrev_state": "ES", "code_region": "3", "name_region": "Sudeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -40.322208726726615, -20.320153792853301 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 3304557.0, "name_muni": "Rio De Janeiro", "code_state": "33", "abbrev_state": "RJ", "code_region": "3", "name_region": "Sudeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -43.22787512499518, -22.876652118186449 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 3550308.0, "name_muni": "São Paulo", "code_state": "35", "abbrev_state": "SP", "code_region": "3", "name_region": "Sudeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -46.570383182112742, -23.5673865 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 4106902.0, "name_muni": "Curitiba", "code_state": "41", "abbrev_state": "PR", "code_region": "4", "name_region": "Sul", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -49.271847885077406, -25.432956 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 4205407.0, "name_muni": "Florianópolis", "code_state": "42", "abbrev_state": "SC", "code_region": "4", "name_region": "Sul", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -48.547637378193322, -27.587795548549948 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 4314902.0, "name_muni": "Porto Alegre", "code_state": "43", "abbrev_state": "RS", "code_region": "4", "name_region": "Sul", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -51.228660463702326, -30.030036774766394 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 5002704.0, "name_muni": "Campo Grande", "code_state": "50", "abbrev_state": "MS", "code_region": "5", "name_region": "Centro Oeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -54.615743566458832, -20.458029987863899 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 5103403.0, "name_muni": "Cuiabá", "code_state": "51", "abbrev_state": "MT", "code_region": "5", "name_region": "Centro Oeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -56.073252038191129, -15.569989013120598 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 5208707.0, "name_muni": "Goiânia", "code_state": "52", "abbrev_state": "GO", "code_region": "5", "name_region": "Centro Oeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -49.255814275815752, -16.673309773838945 ] } }, | |
{ "type": "Feature", "properties": { "code_muni": 5300108.0, "name_muni": "Brasília", "code_state": "53", "abbrev_state": "DF", "code_region": "5", "name_region": "Centro Oeste", "year": "2010" }, "geometry": { "type": "Point", "coordinates": [ -47.887905478031328, -15.794087361890998 ] } } | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment