Skip to content
Back to skills

Stars

ASecurity

R stars package for spatiotemporal arrays. Use for raster data cubes and time series of rasters.

  • 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 stars --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stars?

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

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

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: stars
description: R stars package for spatiotemporal arrays. Use for raster data cubes and time series of rasters.
---

# stars Package

Spatiotemporal arrays (raster/vector data cubes).

## Read Data

```r
library(stars)

# Single file
r <- read_stars("file.tif")

# Multiple files (time series)
files <- list.files(pattern = "*.tif")
r <- read_stars(files, along = "time")

# NetCDF
nc <- read_stars("file.nc")
```

## Create

```r
# From matrix
m <- matrix(1:20, 4, 5)
s <- st_as_stars(m)

# With dimensions
s <- st_as_stars(list(values = m),
  dimensions = st_dimensions(
    x = 1:4,
    y = 1:5
  )
)
```

## Dimensions

```r
# View dimensions
st_dimensions(r)

# Set dimension values
r <- st_set_dimensions(r, "time", values = dates)

# Rename dimensions
r <- setNames(r, "temperature")
```

## Operations

```r
# Subset
r[, 1:10, 1:10]
r[, , , 1:5]  # First 5 time steps

# Aggregate
r_agg <- st_apply(r, c("x", "y"), mean)

# Warp (reproject)
r_warp <- st_warp(r, crs = 4326)

# Crop
r_crop <- st_crop(r, bbox)
```

## With sf

```r
library(sf)

# Extract by polygons
vals <- aggregate(r, polygons, FUN = mean)

# Rasterize
r <- st_rasterize(sf_obj)
```

## Plot

```r
plot(r)

# With ggplot2
library(ggplot2)
ggplot() +
  geom_stars(data = r) +
  scale_fill_viridis_c()
```

## Write

```r
write_stars(r, "output.tif")
```

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…