
Assign Kopppen-Geiger Climate Zones to Brazilian Municipalities
Source:R/sus_grid_koppen.R
sus_grid_koppen.RdAdds a zona_koppen column to a climasus_df (or plain data.frame) with
municipality-level Koppen-Geiger climate classification following
Alvares et al. (2013), who produced the first high-resolution (1 km) Koppen
map for Brazil.
Usage
sus_grid_koppen(
data,
mode = "approx",
koppen_sf = NULL,
as_factor = TRUE,
lang = "pt",
verbose = TRUE
)Arguments
- data
A
climasus_dfordata.framecontaining acode_municolumn (6- or 7-digit IBGE municipality code), or ansfobject of Brazilian municipalities.- mode
Character. Assignment mode:
"approx"(default, no extra dependencies) or"exact"(requiressfandkoppen_sf).- koppen_sf
An
sfpolygon object with a column namedkoppencontaining the zone codes ("Af","Am", etc.). Required whenmode = "exact". The Alvares et al. (2013) shapefile is available at https://doi.org/10.1127/0941-2948/2013/0507. Ignored formode = "approx".- as_factor
Logical. Return
zona_koppenas an ordered factor with canonical level order (Af < Am < As < Aw < BSh < Cf < Cw)? DefaultTRUE. Set toFALSEto get a plain character column.- lang
Character. Language for messages:
"pt"(default),"en","es".- verbose
Logical. Print progress messages. Default
TRUE.
Value
The input object with an additional column zona_koppen. If the
input was a climasus_df, the returned object preserves its class and
sus_meta attribute with the history updated.
Details
Two assignment modes are available:
"approx"(default): rule-based assignment from municipality centroid coordinates stored in the built-inmunicipio_metatable. Fast and dependency-free, with ~85% accuracy at the municipal level."exact": spatial join between municipality centroids and a user- suppliedsfpolygon layer (koppen_sf). Produces exact results when the original Alvares et al. (2013) shapefile is provided.
Koppen zones for Brazil (Alvares et al. 2013)
- Af
Tropical humid (equatorial) – Amazon / NE coast.
- Am
Tropical monsoon – North / Center-West.
- As
Tropical summer dry – NE coast.
- Aw
Tropical winter dry (savanna) – Central Brazil.
- BSh
Hot semi-arid – NE sertao.
- Cf
Subtropical humid – South / coastal SE.
- Cw
Subtropical winter dry – SE plateau / Center-West uplands.
References
Alvares, C.A., Stape, J.L., Sentelhas, P.C., Goncalves, J.L.M., & Sparovek, G. (2013). Koppen's climate classification map for Brazil. Meteorologische Zeitschrift, 22(6), 711-728. doi:10.1127/0941-2948/2013/0507
Examples
if (FALSE) { # \dontrun{
library(climasus4r)
# With a climasus_df that has code_muni
df_with_koppen <- sus_grid_koppen(df_aggregated, mode = "approx")
table(df_with_koppen$zona_koppen)
# Exact mode with Alvares et al. 2013 shapefile
library(sf)
kop_sf <- sf::read_sf("koppen_brazil_alvares2013.shp")
names(kop_sf)[names(kop_sf) == "zone"] <- "koppen" # rename if needed
df_exact <- sus_grid_koppen(df_aggregated, mode = "exact", koppen_sf = kop_sf)
} # }