Skip to content
Back to skills

R Spatial Mapping

ASecurity

R mapping with tmap, leaflet, mapview. Use for static and interactive maps.

  • 5 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added June 4, 2026
datago

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill r-spatial-mapping --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of R Spatial Mapping?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for R Spatial Mapping
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-r-spatial-mapping/badge)](https://www.skillsdirectory.com/skills/leolin990405-r-spatial-mapping)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: r-spatial-mapping
description: R mapping with tmap, leaflet, mapview. Use for static and interactive maps.
---

# R Mapping

Static and interactive maps.

## tmap

```r
library(tmap)

# Mode
tmap_mode("plot")  # Static
tmap_mode("view")  # Interactive

# Basic map
tm_shape(shp) +
  tm_polygons("variable", palette = "Blues") +
  tm_borders()

# Points
tm_shape(points) +
  tm_dots(col = "value", size = 0.5)

# Lines
tm_shape(roads) +
  tm_lines(col = "type", lwd = 2)

# Complete map
tm_shape(polygons) +
  tm_fill("pop", style = "quantile", palette = "YlOrRd") +
  tm_borders(alpha = 0.5) +
tm_shape(points) +
  tm_symbols(col = "red", size = 0.3) +
tm_layout(
  title = "Map Title",
  legend.position = c("left", "bottom")
) +
tm_compass(position = c("right", "top")) +
tm_scale_bar()

# Save
tmap_save(map, "map.png", width = 10, height = 8)
```

## leaflet

```r
library(leaflet)

# Basic
leaflet() %>%
  addTiles() %>%
  addMarkers(lng = -73.9, lat = 40.7, popup = "NYC")

# With sf
leaflet(shp) %>%
  addTiles() %>%
  addPolygons(
    fillColor = ~colorQuantile("YlOrRd", pop)(pop),
    weight = 1,
    popup = ~name
  )

# Layers
leaflet() %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addCircleMarkers(data = points, radius = 5) %>%
  addPolylines(data = lines, color = "blue") %>%
  addLegend(pal = pal, values = ~value)
```

## mapview

```r
library(mapview)

# Quick view
mapview(shp)
mapview(shp, zcol = "variable")

# Multiple layers
mapview(polygons) + mapview(points, col.regions = "red")

# Options
mapview(shp,
  zcol = "pop",
  layer.name = "Population",
  alpha.regions = 0.7
)
```

## ggplot2 + sf

```r
library(ggplot2)

ggplot(shp) +
  geom_sf(aes(fill = variable)) +
  scale_fill_viridis_c() +
  coord_sf(crs = 4326) +
  theme_minimal()
```

Files in this skill

  • SKILL.md1.7 KB
  • cartography/SKILL.md1.8 KB
  • ggmap/SKILL.md1.6 KB
  • mapsf/SKILL.md1.9 KB
  • mapview/SKILL.md1.4 KB
  • tmap/SKILL.md1.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.