Skip to content
Back to skills

Terra

ASecurity

R terra package for spatial data. Use for raster and vector data analysis, successor to raster package.

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

Security analysis

A100/100

Scanned June 4, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Terra?

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

Security grade badge for Terra
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-terra/badge)](https://www.skillsdirectory.com/skills/leolin990405-terra)

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: terra
description: R terra package for spatial data. Use for raster and vector data analysis, successor to raster package.
---

# terra Package

Spatial data analysis (raster and vector).

## Raster Data

```r
library(terra)

# Read raster
r <- rast("file.tif")

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

# Multi-layer
r <- rast(c("band1.tif", "band2.tif", "band3.tif"))
```

## Raster Operations

```r
# Basic info
dim(r)
res(r)
ext(r)
crs(r)

# Algebra
r2 <- r * 2
r3 <- r + r2
r4 <- sqrt(r)

# Aggregate/Disaggregate
r_agg <- aggregate(r, fact = 2, fun = mean)
r_dis <- disagg(r, fact = 2)

# Resample
r_resamp <- resample(r, template_raster)

# Crop/Mask
r_crop <- crop(r, extent)
r_mask <- mask(r, polygon)
```

## Vector Data

```r
# Read vector
v <- vect("file.shp")
v <- vect("file.gpkg")

# Create from coordinates
pts <- vect(cbind(x, y), crs = "EPSG:4326")

# From sf
v <- vect(sf_object)
sf_obj <- st_as_sf(v)
```

## Vector Operations

```r
# Buffer
v_buf <- buffer(v, width = 1000)

# Intersect
v_int <- intersect(v1, v2)

# Union
v_union <- union(v1, v2)

# Extract raster values
vals <- extract(r, v)
```

## Write

```r
writeRaster(r, "output.tif")
writeVector(v, "output.shp")
```

## Plot

```r
plot(r)
plot(v, add = TRUE)
```

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…