Skip to content
Back to skills

R Spatial Raster

ASecurity

R raster spatial data with terra, raster, stars. Use for gridded data, satellite imagery, and raster analysis.

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

Security analysis

A100/100

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

Scanned June 4, 2026

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

Installs into .claude/skills of the current project.

Are you the author of R Spatial Raster?

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

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

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-raster
description: R raster spatial data with terra, raster, stars. Use for gridded data, satellite imagery, and raster analysis.
---

# R Raster Spatial Data

Gridded and imagery data.

## terra

```r
library(terra)

# Read/write
r <- rast("file.tif")
writeRaster(r, "output.tif")

# Create raster
r <- rast(nrows = 100, ncols = 100, xmin = 0, xmax = 10, ymin = 0, ymax = 10)
values(r) <- runif(ncell(r))

# Multi-layer
stack <- c(r1, r2, r3)
r[[1]]  # First layer
names(stack) <- c("band1", "band2", "band3")

# Properties
res(r)
ext(r)
crs(r)
ncell(r)
dim(r)

# Operations
crop(r, extent)
mask(r, polygon)
resample(r, template)
project(r, "EPSG:4326")
aggregate(r, fact = 2)
disagg(r, fact = 2)

# Algebra
r1 + r2
r * 2
log(r)
app(stack, fun = mean)
lapp(stack, fun = function(x, y) x / y)

# Extract
extract(r, points)
extract(r, polygons, fun = mean)

# Focal operations
focal(r, w = 3, fun = mean)
focal(r, w = matrix(1, 3, 3), fun = sum)

# Terrain
terrain(dem, v = c("slope", "aspect"))
shade(slope, aspect)
```

## stars

```r
library(stars)

# Read
s <- read_stars("file.tif")
s <- read_ncdf("file.nc")

# Dimensions
st_dimensions(s)

# Operations
s[, 1:100, 1:100]  # Subset
st_apply(s, c("x", "y"), mean)
st_warp(s, crs = 4326)
```

Files in this skill

  • SKILL.md1.2 KB
  • raster/SKILL.md1.9 KB
  • stars/SKILL.md1.3 KB
  • terra/SKILL.md1.3 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.

View all in data →

Comments

Loading comments…

Newsletter

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