| Title: | Brazilian Maps from Different Geographic Levels |
|---|---|
| Description: | Provides simplified Brazilian territorial meshes derived from official data published by the Brazilian Institute of Geography and Statistics (IBGE) <https://www.ibge.gov.br/> as local spatial objects, with no download required at use time. Municipal meshes cover selected official editions from 2000 onwards whenever the number of municipalities changes, and current meshes are available for states, regions and other geographic levels. Convenience functions support filtering, joining and plotting the maps, as well as consulting Brazilian territorial codes. |
| Authors: | Renato Prado Siqueira [aut, cre] |
| Maintainer: | Renato Prado Siqueira <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-10-09 10:56:20 UTC |
| Source: | https://github.com/rpradosiqueira/brazilmaps |
Returns the inventory generated with the spatial files. The package bundles the latest official edition from each consecutive run with the same municipality count. All listed editions are installed and read locally by [get_brmap()].
brmap_editions() brmap_years()brmap_editions() brmap_years()
A data frame with one row per installed edition and columns 'year', 'n_features', 'file_bytes', 'md5', 'crs', 'simplification' and 'source'. 'source' contains the exact official IBGE archive URL or URLs used by the maintenance pipeline.
brmap_editions()brmap_editions()
Example mortality data for the discontinued IBGE microregions.
deathsdeaths
A data frame with 558 rows and 3 variables:
IBGE microregion code.
Microregion name.
Registered deaths.
DATASUS.
Returns a simplified territorial mesh shipped with the package. No network connection is used. Municipal meshes can be selected by milestone edition year; other levels represent the current bundled snapshot. Parsed maps are cached only in memory for the duration of the R session.
get_brmap( level = "country", filters = NULL, output = c("sf", "data.frame", "sp"), year = NULL, geo = NULL, geo_filter = NULL, as = NULL, geo.filter = NULL, class = NULL )get_brmap( level = "country", filters = NULL, output = c("sf", "data.frame", "sp"), year = NULL, geo = NULL, geo_filter = NULL, as = NULL, geo.filter = NULL, class = NULL )
level |
Geographic level in lower snake case. One of '"country"', '"region"', '"state"', '"state_hex"', '"state_region"', '"intermediate_region"', '"immediate_region"', '"mesoregion"', '"microregion"' or '"municipality"'. |
filters |
Optional named list of code filters. Level shorthands such as 'list(region = 5, state = 50)' are accepted and combined with logical AND. |
output |
Output type: '"sf"', '"data.frame"' or '"sp"'. |
year |
Bundled municipal mesh edition. 'NULL' selects the most recent edition. Historical years are available only for municipalities. |
geo, geo_filter, as
|
Deprecated aliases for 'level', 'filters' and 'output'. |
geo.filter, class
|
Older deprecated aliases for 'filters' and 'output'. |
The meshes are intended for thematic mapping, exploratory analysis and joins. They are not suitable for cadastral work, legal boundary decisions or precise area and perimeter measurement. Historical municipal geometries receive current immediate, intermediate, microregion and mesoregion attributes when their municipality codes can be matched to the bundled current DTB.
An 'sf' object by default. '"data.frame"' removes the geometry; '"sp"' returns a legacy 'Spatial' object and requires package 'sp'.
[brmap_editions()], [join_brmap()], [plot_brmap()]
rio <- get_brmap("state", filters = list(state = 33)) municipalities_2010 <- get_brmap( "municipality", year = 2010, filters = list(region = 5) ) plot_brmap(rio)rio <- get_brmap("state", filters = list(state = 33)) municipalities_2010 <- get_brmap( "municipality", year = 2010, filters = list(region = 5) ) plot_brmap(rio)
Looks up territorial identifiers and their hierarchy in the version of the Brazilian Territorial Division (DTB) shipped with the package.
get_dtb(code = NULL, name = NULL)get_dtb(code = NULL, name = NULL)
code |
Optional vector of IBGE territorial codes. |
name |
Optional vector of territory names. Matching ignores case and surrounding whitespace. |
A data frame. If both arguments are 'NULL', the complete bundled snapshot is returned. If both are supplied, rows matching either condition are returned. A query with no matches returns zero rows while preserving the complete column schema.
[get_dtb_levels()]
get_dtb(code = c(50, 5002704, 1)) get_dtb(name = c("Campo Grande", "Recife"))get_dtb(code = c(50, 5002704, 1)) get_dtb(name = c("Campo Grande", "Recife"))
'get_dtb_info()' is retained for compatibility. Use [get_dtb()] with argument 'code' and lower-snake-case output columns.
get_dtb_info(cod = NULL, name = NULL)get_dtb_info(cod = NULL, name = NULL)
cod |
Optional vector of IBGE territorial codes. |
name |
Optional vector of territory names. |
A data frame using the legacy DTB column names.
Returns codes and names for one or more territorial levels using the hierarchy shipped with the package.
get_dtb_levels( levels = c("municipality", "state", "region", "immediate_region", "intermediate_region", "microregion", "mesoregion"), filters = NULL )get_dtb_levels( levels = c("municipality", "state", "region", "immediate_region", "intermediate_region", "microregion", "mesoregion"), filters = NULL )
levels |
Character vector containing any of '"municipality"', '"state"', '"region"', '"immediate_region"', '"intermediate_region"', '"microregion"' and '"mesoregion"'. |
filters |
Optional named list of codes used to filter the result. Conditions are combined with logical AND. |
A data frame with explicit code/name pairs for the requested levels.
[get_dtb()]
get_dtb_levels(c("municipality", "region")) get_dtb_levels(c("state", "immediate_region"))get_dtb_levels(c("municipality", "region")) get_dtb_levels(c("state", "immediate_region"))
'get_dtb_lvl()' is retained for compatibility. Use [get_dtb_levels()].
get_dtb_lvl( geo = c("City", "State", "Region", "Immediate", "Intermediary", "MicroRegion", "MesoRegion"), geo_filter = NULL )get_dtb_lvl( geo = c("City", "State", "Region", "Immediate", "Intermediary", "MicroRegion", "MesoRegion"), geo_filter = NULL )
geo |
Legacy geographic level names. |
geo_filter |
Optional named list of legacy filters. |
A data frame using the legacy DTB column names.
Example data containing the 2015 Gini index by state.
gini2015gini2015
A data frame with 27 rows and 3 variables:
IBGE state code.
State name.
Gini index.
Brazilian Institute of Geography and Statistics (IBGE).
A small type-preserving wrapper around [dplyr::left_join()].
join_brmap(map, data, by = NULL) join_data(map, data, by = NULL)join_brmap(map, data, by = NULL) join_data(map, data, by = NULL)
map |
An 'sf', 'SpatialPolygonsDataFrame' or 'data.frame' object. |
data |
A data frame containing the columns to add. |
by |
Join specification accepted by [dplyr::left_join()]. |
The same broad object type supplied in 'map'.
[get_brmap()]
data("pop2017") municipalities <- get_brmap("municipality", year = 2023) municipalities <- join_brmap( municipalities, pop2017, by = c("municipality_code" = "mun") )data("pop2017") municipalities <- get_brmap("municipality", year = 2023) municipalities <- join_brmap( municipalities, pop2017, by = c("municipality_code" = "mun") )
Creates a 'ggplot' using [ggplot2::geom_sf()]. The returned object can be extended with any regular ggplot2 layer, scale or label.
plot_brmap( map, data = NULL, by = NULL, fill_by = NULL, theme = theme_brmap(), border_colour = "grey30", border_linewidth = 0.15, fill = "white", data_to_join = NULL, join_by = NULL, var = NULL )plot_brmap( map, data = NULL, by = NULL, fill_by = NULL, theme = theme_brmap(), border_colour = "grey30", border_linewidth = 0.15, fill = "white", data_to_join = NULL, join_by = NULL, var = NULL )
map |
An 'sf' or legacy 'Spatial' polygon object. |
data |
Optional data frame to join before plotting. |
by |
Join specification accepted by [dplyr::left_join()]. |
fill_by |
Optional single column name mapped to polygon fill. |
theme |
A complete or partial ggplot2 theme. |
border_colour |
Polygon border colour. |
border_linewidth |
Polygon border width. |
fill |
Constant fill used when 'fill_by' is 'NULL'. |
data_to_join, join_by, var
|
Deprecated aliases for 'data', 'by' and 'fill_by'. |
A 'ggplot' object.
[get_brmap()], [join_brmap()]
data("pop2017") south <- get_brmap( "municipality", year = 2023, filters = list(region = 4) ) plot_brmap( south, data = pop2017, by = c("municipality_code" = "mun"), fill_by = "pop2017" )data("pop2017") south <- get_brmap( "municipality", year = 2023, filters = list(region = 4) ) plot_brmap( south, data = pop2017, by = c("municipality_code" = "mun"), fill_by = "pop2017" )
Example data containing 2017 municipal population estimates.
pop2017pop2017
A data frame with 5,570 rows and 3 variables:
IBGE municipality code.
Municipality name.
Estimated 2017 population.
Brazilian Institute of Geography and Statistics (IBGE).
Minimal theme for Brazilian maps
theme_brmap(base_size = 9, base_family = "") theme_map(base_size = 9, base_family = "")theme_brmap(base_size = 9, base_family = "") theme_map(base_size = 9, base_family = "")
base_size |
Base font size. |
base_family |
Base font family. |
A ggplot2 theme.