rk.rnaturalearth: Easy Choropleth Maps for RKWard

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.

πŸš€ Features

1. Modular Workflow

2. Advanced Visualization Tools

3. Professional Cartography Elements (ggspatial & ggrepel)

4. Data Helpers

πŸ“¦ Installation

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

🌍 Internationalization

This plugin is fully localized and automatically adapts to the language settings of your RKWard installation.

Supported Languages:

If your system language is not listed, the interface will default to English.

πŸ’» Usage

Once installed, the tools are organized under:

Plots -> Maps

  1. Download -> Download Country Map Object: Start here to get the shapefile.
  2. Plot Continuous Map: For numeric heatmaps.
  3. Plot Categorical Map: For grouping/regions.
  4. Get Map Names: To check spelling.
  5. Recode Map Regions: To fix spelling errors in the map object.
  6. Transform Map Projection: To convert CRS (e.g., Lat/Lon to Meters).

πŸŽ“ Quick Start Examples

Example 1: The Basic Workflow (Continuous)

Scenario: Visualizing random "Satisfaction Scores" for Mexico.

Step 1: Download Map

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


Example 2: Categorical Regions

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


Example 3: Fixing Scale Bars (Projection)

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).

  1. Open Transform Map Projection.
  2. Map Object: map_mx.
  3. Target Projection: Mexico ITRF2008 / LCC (6362) (or Web Mercator).
  4. Save As: map_mx_projected.
  5. Use map_mx_projected in the Plotting plugins. The scale bar will now be accurate.

πŸ› οΈ Dependencies

This plugin relies on the following R packages:

✍️ Author & License