https://github.com/mdsumner/nchelper
NetCDF variables as R arrays
https://github.com/mdsumner/nchelper
Last synced: 4 months ago
JSON representation
NetCDF variables as R arrays
- Host: GitHub
- URL: https://github.com/mdsumner/nchelper
- Owner: mdsumner
- Created: 2013-08-01T12:26:13.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2018-02-22T07:33:02.000Z (over 8 years ago)
- Last Synced: 2025-06-17T20:40:22.491Z (12 months ago)
- Language: R
- Homepage: http://mdsumner.github.io/nchelper/
- Size: 2.08 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://travis-ci.org/mdsumner/nchelper)
[](https://travis-ci.org/mdsumner/nchelper)
[](https://ci.appveyor.com/project/mdsumner/nchelper)
# nchelper
The goal of nchelper is to provide NetCDF variables as R arrays.
## Installation
You can install nchelper from GitHub with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("mdsumner/nchelper")
```
## Example
This is an example that reads an inbuilt data set of sea surface temperature.
First, find the file and open the variable "sst" as object `a`.
```{r example}
library(nchelper)
f <- system.file("extdata", "avhrr-only-v2.20180126.nc", package = "nchelper")
a <- nchelper(f, "sst")
dim(a)
names(a)
```
(Even though we asked for the variable "sst", we could also
see other names if there were any available.)
Now use standard indexing idioms to extract data from this 4D array.
```{r four-d}
grcol <- grey(seq(0, 1, length.out = 12))
image(a[,,,], col = grcol)
image(a[400:800, 100:300,,], col = grcol)
plot(a[,360,,] * 0.01, ylim = c(20, 32), type = "l")
```
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
By participating in this project you agree to abide by its terms.