Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
8 of 43 committers (18.6%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.6%) to scientific vocabulary
Keywords
r
raster
satellite-images
spatial
Keywords from Contributors
geo
gdal
proj
visualisation
book
rspatial
geospatial-data
geography
tidy-data
geocomputation
Last synced: 6 months ago
·
JSON representation
Repository
Spatiotemporal Arrays, Raster and Vector Data Cubes
Basic Info
- Host: GitHub
- Owner: r-spatial
- License: apache-2.0
- Language: R
- Default Branch: main
- Homepage: https://r-spatial.github.io/stars/
- Size: 251 MB
Statistics
- Stars: 583
- Watchers: 36
- Forks: 94
- Open Issues: 40
- Releases: 0
Topics
r
raster
satellite-images
spatial
Created about 9 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r setup, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
fig.path = "man/figures/README-"
)
is_online = curl::has_internet()
```
# Spatiotemporal Arrays: Raster and Vector Datacubes
[](https://github.com/r-spatial/stars/actions/workflows/R-CMD-check.yaml)
[](https://cran.r-project.org/package=stars)
[](https://cran.r-project.org/web/checks/check_results_stars.html)
[](https://www.r-pkg.org/pkg/stars)
[](https://CRAN.R-project.org/package=stars)
[](https://app.codecov.io/gh/r-spatial/stars?branch=main)
Spatiotemporal data often comes in the form of dense arrays, with space and time being array dimensions. Examples include
- socio-economic or demographic data,
- environmental variables monitored at fixed stations,
- raster maps,
- time series of satellite images with multiple spectral bands,
- spatial simulations, and
- climate or weather model output.
This R package provides classes and methods for reading,
manipulating, plotting and writing such data cubes, to the extent
that there are proper formats for doing so.
## Raster and vector data cubes
The canonical data cube most of us have in mind is that where two
dimensions represent spatial raster dimensions, and the third time
(or band), as e.g. shown here:
```{r cube1,out.width='50%',echo=FALSE}
knitr::include_graphics("https://raw.githubusercontent.com/r-spatial/stars/main/images/cube1.png")
```
By data cubes however we also consider higher-dimensional cubes
(hypercubes) such as a five-dimensional cube where in addition to
time, spectral band and sensor form dimensions:
```{r cube2,out.width='50%',echo=FALSE}
knitr::include_graphics("https://raw.githubusercontent.com/r-spatial/stars/main/images/cube2.png")
```
or lower-dimensional cubes such as a raster image:
```{r plot1, message=FALSE}
library(dplyr)
library(stars)
tif = system.file("tif/L7_ETMs.tif", package = "stars")
read_stars(tif) |>
slice(index = 1, along = "band") |>
plot()
```
Raster data do not need to be regular and aligned with North/East,
and package `stars` supports besides _regular_ also _rotated_,
_sheared_, _rectilinear_ and _curvilinear_ rasters:
```{r plot2,echo=FALSE}
x = 1:5
y = 1:4
d = st_dimensions(x = x, y = y, .raster = c("x", "y"))
m = matrix(runif(20),5,4)
r1 = st_as_stars(r = m, dimensions = d)
r = attr(d, "raster")
r$affine = c(0.2, -0.2)
attr(d, "raster") = r
r2 = st_as_stars(r = m, dimensions = d)
r = attr(d, "raster")
r$affine = c(0.1, -0.3)
attr(d, "raster") = r
r3 = st_as_stars(r = m, dimensions = d)
x = c(1, 2, 3.5, 5, 6)
y = c(1, 1.5, 3, 3.5)
d = st_dimensions(x = x, y = y, .raster = c("x", "y"))
r4 = st_as_stars(r = m, dimensions = d)
grd = st_make_grid(cellsize = c(10,10), offset = c(-130,10), n = c(8,5), crs = st_crs(4326))
r5 = st_transform(grd, "+proj=laea +lon_0=-70 +lat_0=35")
par(mfrow = c(2,3))
r1 = st_make_grid(cellsize = c(1,1), n = c(5,4), offset = c(0,0))
plot(r1, main = "regular")
plot(st_geometry(st_as_sf(r2)), main = "rotated")
plot(st_geometry(st_as_sf(r3)), main = "sheared")
plot(st_geometry(st_as_sf(r4, as_points = FALSE)), main = "rectilinear")
plot(st_geometry((r5)), main = "curvilinear")
```
Vector data cubes arise when we do not have two regularly discretized spatial dimensions, but a single dimension that points to distinct spatial feature geometries, such as polygons (e.g. denoting administrative regions):
```{r cube3,out.width='50%',echo=FALSE}
knitr::include_graphics("https://raw.githubusercontent.com/r-spatial/stars/main/images/cube3.png")
```
or points (e.g. denoting sensor locations):
```{r cube4,out.width='50%',echo=FALSE}
knitr::include_graphics("https://raw.githubusercontent.com/r-spatial/stars/main/images/cube4.png")
```
NetCDF's CF-convention calls this a [discrete axis](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#discrete-axis).
## NetCDF, GDAL
`stars` provides two functions to read data: `read_ncdf` and
`read_stars`, where the latter reads through GDAL. (In the future,
both will be integrated in `read_stars`.) For reading NetCDF files,
package `RNetCDF` is used, for reading through GDAL, package `sf`
provides the binary linking to GDAL.
For vector and raster operations, `stars` uses as much as possible
the routines available in GDAL and PROJ (e.g. `st_transform`,
`rasterize`, `polygonize`, `warp`). Read more about this in
the vignette on [vector-raster conversions, reprojection,
warping](https://r-spatial.github.io/stars/articles/stars5.html).
## Out-of-memory (on-disk) rasters
Package `stars` provides `stars_proxy` objects (currently only when
read through GDAL), which contain only the dimensions metadata and
pointers to the files on disk. These objects work lazily: reading
and processing data is postponed to the moment that pixels are
really needed (at plot time, or when writing to disk), and is done
at the lowest spatial resolution possible that still fulfills the
resolution of the graphics device. More
details are found in the [stars proxy
vignette](https://r-spatial.github.io/stars/articles/stars2.html).
The following methods are currently available for `stars_proxy` objects:
```{r methods}
methods(class = "stars_proxy")
```
## Raster and vector time series analysis example
In the following, a curvilinear grid with hourly precipitation values of
a hurricane is imported and the first 12 time steps are plotted:
```{r plot3}
prec_file = system.file("nc/test_stageiv_xyt.nc", package = "stars")
(prec = read_stars(gdal_subdatasets(prec_file)[[1]]))
# or: (prec = read_ncdf(prec_file, curvilinear = c("lon", "lat"), ignore_bounds = TRUE))
sf::read_sf(system.file("gpkg/nc.gpkg", package = "sf"), "nc.gpkg") |>
st_transform(st_crs(prec)) -> nc # transform from NAD27 to WGS84
nc_outline = st_union(st_geometry(nc))
plot_hook = function() plot(nc_outline, border = 'red', add = TRUE)
prec |>
slice(index = 1:12, along = "time") |>
plot(downsample = c(3, 3, 1), hook = plot_hook)
```
and next, intersected with with the counties of North Carolina, where
the maximum precipitation intensity was obtained per county, and plotted:
```{r plot4}
a = aggregate(prec, by = nc, FUN = max)
plot(a, max.plot = 23, border = 'grey', lwd = .5)
```
We can integrate over (reduce) time, for instance to find out _when_
the maximum precipitation occurred. The following code finds the time
index, and then the corresponding time value:
```{r plot5, fig.height=3}
index_max = function(x) ifelse(all(is.na(x)), NA, which.max(x))
b = st_apply(a, "geom", index_max)
b |> mutate(when = st_get_dimension_values(a, "time")[b$index_max]) |>
select(when) |>
plot(key.pos = 1, main = "time of maximum precipitation")
```
With package `cubble`, we can make a glyph map to see the magnitude and timings of county maximum precipitation:
```{r plot6, fig.height=3, message=FALSE, warning=FALSE}
library(cubble)
library(ggplot2)
a |> setNames("precip") |>
st_set_dimensions(2, name = "tm") |>
units::drop_units() |>
as_cubble(key = id, index = tm) -> a.cb
a.cb |>
face_temporal() |>
unfold(long, lat) |>
mutate(tm = as.numeric(tm)) |>
ggplot(aes(x_major = long, x_minor = tm, y_major = lat, y_minor = precip)) +
geom_sf(data = nc, inherit.aes = FALSE) +
geom_glyph_box(width = 0.3, height = 0.1) +
geom_glyph(width = 0.3, height = 0.1)
```
## Other packages for data cubes
### [`gdalcubes`](https://github.com/appelmar/gdalcubes)
Package `gdalcubes` can be used to create data cubes (or functions
from them) from image collections, sets of multi-band images with
varying
* spatial resolution
* spatial extent
* coordinate reference systems (e.g., spread over multiple UTM zones)
* observation times
and does this by resampling and/or aggregating over space and/or
time. It reuses GDAL VRT's and gdalwarp for spatial resampling and/or
warping, and handles temporal resampling or aggregation itself.
### [`ncdfgeom`](https://github.com/DOI-USGS/ncdfgeom)
`ncdfgeom` reads and writes vector data cubes from and to netcdf
files in a standards-compliant way.
### [`raster`](https://github.com/rspatial/raster/) and [`terra`](https://github.com/rspatial/terra/)
Packages `raster` and its successor, `terra` are powerful packages
for handling raster maps and stacks of raster maps both in memory
and on disk, but do not address
* non-raster time series,
* multi-attribute rasters time series
* rasters with mixed type attributes (e.g., numeric, logical, factor, POSIXct)
* rectilinear or curvilinear rasters
A list of `stars` commands matching
existing `raster` commands is found in this
[wiki](https://github.com/r-spatial/stars/wiki/How-%60raster%60-functions-map-to-%60stars%60-functions).
A list of translations in the opposite direction (from `stars` to
`raster` or `terra`) still needs to be made.
A comment on the differences between `stars` and `terra` is found
[here](https://github.com/r-spatial/stars/issues/633).
## Other `stars` resources:
* blog posts: [first](https://r-spatial.org/r/2017/11/23/stars1.html),
[second](https://r-spatial.org/r/2018/03/22/stars2.html),
[third](https://r-spatial.org/r/2018/03/23/stars3.html), and [newer blog posts](https://r-spatial.org/)
* [vignettes](https://r-spatial.github.io/stars/articles/)
* the original [R Consortium proposal](https://github.com/r-spatial/stars/blob/main/PROPOSAL.md).
### Acknowledgment
This project has been realized with financial
[support](https://www.r-consortium.org/blog/2017/04/03/q1-2017-isc-grants)
from the
Owner
- Name: r-spatial
- Login: r-spatial
- Kind: organization
- Website: https://github.com/r-spatial
- Repositories: 43
- Profile: https://github.com/r-spatial
For packages raster, terra, dismo & geosphere visit the rspatial github organisation (mind the missing '-')
GitHub Events
Total
- Issues event: 48
- Watch event: 20
- Issue comment event: 98
- Push event: 76
- Pull request review comment event: 7
- Pull request review event: 7
- Pull request event: 8
- Fork event: 2
Last Year
- Issues event: 48
- Watch event: 20
- Issue comment event: 98
- Push event: 76
- Pull request review comment event: 7
- Pull request review event: 7
- Pull request event: 8
- Fork event: 2
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Edzer Pebesma | e****a@u****e | 1,640 |
| David Blodgett | d****t@u****v | 62 |
| Krzysztof Dyba | 3****b | 46 |
| Michael Sumner | m****r@g****m | 46 |
| loreabad6 | l****6@g****m | 26 |
| pat-s | p****z@g****m | 24 |
| Jakub Nowosad | t****i@g****m | 22 |
| gabo | g****2@g****m | 9 |
| olivroy | o****1@h****m | 7 |
| Kendon Bell | k****B | 7 |
| Guido Kraemer | g****r@u****e | 6 |
| Ben Tupper | b****r@b****g | 5 |
| Martijn Tennekes | m****s@g****m | 4 |
| floriandeboissieu | f****s@g****m | 3 |
| Shinya Uryu | u****a@n****p | 3 |
| JoshOBrien | j****n@g****m | 3 |
| Andy Teucher | a****r@g****a | 3 |
| Kevin Cazelles | k****e@u****a | 3 |
| rubak | r****k@m****k | 2 |
| github-actions[bot] | 4****] | 2 |
| Timofey Samsonov | t****v@g****u | 2 |
| bart1 | 1****1 | 1 |
| michaeldorman | m****n@m****l | 1 |
| przell | 5****l | 1 |
| rhijmans | r****s@g****m | 1 |
| rushgeo | 1****o | 1 |
| Alex Ilich | a****h@u****u | 1 |
| bart | y****u@e****m | 1 |
| Toby C. Wilkinson | o****n@t****k | 1 |
| Sébastien Rochette | s****r@g****m | 1 |
| and 13 more... | ||
Committer Domains (Top 20 + Academic)
uni-muenster.de: 2
usgs.gov: 1
uni-leipzig.de: 1
bigelow.org: 1
nies.go.jp: 1
gov.bc.ca: 1
uoguelph.ca: 1
math.aau.dk: 1
geogr.msu.ru: 1
mail.huji.ac.il: 1
usf.edu: 1
tobywilkinson.co.uk: 1
sesync.org: 1
agro.unc.edu.ar: 1
ens-lyon.fr: 1
gmx.de: 1
weecology.org: 1
unsw.edu.au: 1
gmx.net: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 190
- Total pull requests: 52
- Average time to close issues: 4 months
- Average time to close pull requests: 25 days
- Total issue authors: 104
- Total pull request authors: 16
- Average comments per issue: 4.2
- Average comments per pull request: 2.33
- Merged pull requests: 34
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 37
- Pull requests: 13
- Average time to close issues: 5 days
- Average time to close pull requests: about 1 month
- Issue authors: 29
- Pull request authors: 3
- Average comments per issue: 0.81
- Average comments per pull request: 2.0
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- kadyb (19)
- alexyshr (11)
- edzer (8)
- btupper (8)
- dominicroye (6)
- dmkaplan2000 (4)
- agila5 (4)
- jvandens (4)
- fgoerlich (4)
- pvanlaake (3)
- adrfantini (3)
- rsbivand (3)
- Nowosad (3)
- pepijn-devries (3)
- cboettig (2)
Pull Request Authors
- kadyb (13)
- loreabad6 (10)
- dblodgett-usgs (6)
- pvanlaake (4)
- tsamsonov (3)
- btupper (3)
- huizezhang-sherry (2)
- agila5 (2)
- edzer (2)
- bart1 (1)
- iod-ine (1)
- rhijmans (1)
- Nowosad (1)
- a-benini (1)
- tcwilkinson (1)
Top Labels
Issue Labels
reprex needed (5)
enhancement (1)
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- cran 36,473 last-month
- Total docker downloads: 925,361
-
Total dependent packages: 81
(may contain duplicates) -
Total dependent repositories: 170
(may contain duplicates) - Total versions: 32
- Total maintainers: 1
cran.r-project.org: stars
Spatiotemporal Arrays, Raster and Vector Data Cubes
- Homepage: https://r-spatial.github.io/stars/
- Documentation: http://cran.r-project.org/web/packages/stars/stars.pdf
- License: Apache License version 1.1 | Apache License version 2.0 [expanded from: Apache License]
-
Latest release: 0.6-8
published about 1 year ago
Rankings
Docker downloads count: 0.0%
Stargazers count: 0.7%
Forks count: 0.8%
Average: 1.0%
Dependent packages count: 1.3%
Dependent repos count: 1.5%
Downloads: 2.0%
Maintainers (1)
Last synced:
6 months ago
conda-forge.org: r-stars
- Homepage: https://r-spatial.github.io/stars/, https://github.com/r-spatial/stars/
- License: Apache-2.0
-
Latest release: 0.5_5
published about 4 years ago
Rankings
Dependent packages count: 8.0%
Average: 15.3%
Dependent repos count: 16.0%
Stargazers count: 17.8%
Forks count: 19.6%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.3.0 depends
- abind * depends
- sf >= 1.0 depends
- classInt >= 0.4 imports
- lwgeom * imports
- methods * imports
- parallel * imports
- rlang * imports
- units * imports
- Cairo * suggests
- FNN * suggests
- OpenStreetMap * suggests
- PCICt * suggests
- RNetCDF >= 1.8 suggests
- clue * suggests
- covr * suggests
- cubelyr * suggests
- digest * suggests
- dplyr >= 0.7 suggests
- exactextractr * suggests
- future.apply * suggests
- ggforce * suggests
- ggplot2 * suggests
- ggthemes * suggests
- gstat * suggests
- httr * suggests
- jsonlite * suggests
- knitr * suggests
- mapdata * suggests
- maps * suggests
- ncdfgeom * suggests
- ncmeta >= 0.0.3 suggests
- pbapply * suggests
- plm * suggests
- randomForest * suggests
- raster * suggests
- rgdal * suggests
- rmarkdown * suggests
- sp * suggests
- spacetime * suggests
- spatstat >= 2.0 suggests
- spatstat.geom * suggests
- starsdata * suggests
- terra >= 1.4 suggests
- testthat * suggests
- tidyr * suggests
- viridis * suggests
- xts * suggests
- zoo * suggests
inst/docker/fedora/Dockerfile
docker
- fedora latest build
inst/docker/rdevel/Dockerfile
docker
- ubuntu 16.04 build
inst/docker/trusty/Dockerfile
docker
- ubuntu 14.04 build
inst/docker/ubuntu/Dockerfile
docker
- ubuntu 16.04 build
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite