rk.rnaturalearth is a user-friendly wrapper for the rnaturalearth, sf, and ggspatial packages within RKWard. It allows users to generate high-quality administrative Choropleth maps (heat maps based on regions) without needing complex GIS knowledge or shapefile management.
This plugin creates a professional, modular workflow for spatial analysis: Download -> Transform -> Process -> Plot.
rnaturalearth and save them as sf objects in your workspace.Continuous Maps: Plot numeric variables (e.g., Population, Income) using color-blind friendly Viridis palettes.
Categorical Maps: Plot discrete groups (e.g., "North vs South", "Electoral Districts") using RColorBrewer palettes or manual colors.
Deep Styling Control:
ggspatial & ggrepel)check_overlap).Max Overlaps setting to force labels to appear even in dense areas (e.g., small states in the Northeast USA).To install this plugin in RKWard, copy and run the following code in your R Console:
# install.packages("devtools")
local({
require(devtools)
install_github("AlfCano/rk.rnaturalearth", force = TRUE)
})
Note on System Dependencies:
This plugin relies on the sf package. On Linux (Ubuntu/Debian), you may need to install system libraries first:
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev
This plugin is fully localized and automatically adapts to the language settings of your RKWard installation.
Supported Languages:
es)fr)de)pt_BR)If your system language is not listed, the interface will default to English.
Once installed, the tools are organized under:
Plots -> Maps
Scenario: Visualizing random "Satisfaction Scores" for Mexico.
Step 1: Download Map
map_mx.Step 2: Prepare Data (Run in Console)
# Create synthetic data matching the downloaded map
my_mexico_data <- data.frame(
StateName = map_mx$name,
Score = runif(nrow(map_mx), min = 50, max = 100)
)
Step 3: Plot
map_mx.my_mexico_data.name (Map) and StateName (Data).Score.Magma, Grid Clean (Void).Scenario: Coloring states by "Study Region" (North, Center, South).
Step 1: Download map_mx (if not already done).
Step 2: Prepare Data (Run in Console)
# Assign regions randomly for demonstration
my_regions <- data.frame(
StateName = map_mx$name,
Region = sample(c("North", "Center", "South"), nrow(map_mx), replace = TRUE)
)
Step 3: Plot
map_mx.my_regions.Region.Brewer: Set3.White.Right.Problem: You get a warning "Scale on map varies by more than 10%". Solution: The map is in Degrees (Curved), but needs to be in Meters (Flat).
map_mx.Mexico ITRF2008 / LCC (6362) (or Web Mercator).map_mx_projected.map_mx_projected in the Plotting plugins. The scale bar will now be accurate.This plugin relies on the following R packages:
rnaturalearth (Map data source)sf (Simple Features for spatial handling)ggplot2 (Plotting engine)ggspatial (North arrows and scales)ggrepel (Smart label positioning)viridis (Color blindness-friendly palettes)RColorBrewer (Categorical palettes)dplyr (Data manipulation)