https://github.com/meggart/netcdf.jl
NetCDF support for the julia programming language
https://github.com/meggart/netcdf.jl
geo geospatial io julia netcdf raster
Last synced: about 1 month ago
JSON representation
NetCDF support for the julia programming language
- Host: GitHub
- URL: https://github.com/meggart/netcdf.jl
- Owner: meggart
- License: mit
- Created: 2015-09-04T13:10:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-26T11:39:34.000Z (about 2 months ago)
- Last Synced: 2025-04-06T01:34:07.743Z (about 1 month ago)
- Topics: geo, geospatial, io, julia, netcdf, raster
- Language: Julia
- Homepage: http://juliageo.org/NetCDF.jl/
- Size: 7.36 MB
- Stars: 114
- Watchers: 12
- Forks: 28
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
NetCDF.jl
=========| **Documentation** | **Build Status** |
|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
| [![][docs-dev-img]][docs-dev-url] | [![][ci-img]][ci-url]NetCDF support for the Julia programming language, there is a high-level and a medium-level interface for writing and reading netcdf files.
# Missing maintenance warning
This package is currently lacking maintenance. NetCDF.jl should be stable and useful for most operations on NetCDF files, but most users should consider using [NCDatasets.jl](https://github.com/JuliaGeo/NCDatasets.jl) instead, which has more features, like automatic application of CF metadata conventions, is actively maintained and developed and very well documented.
# Installation
```julia
pkg> add NetCDF
```# Quickstart
First, load the library:
```julia
using NetCDF
```The high-level interface is quite similar to the Matlab NetCDF interface, reading files is done by:
```julia
x = ncread("myfile.nc", "Radiation")
```which will read the variable called "Radiation" from the file "myfile.nc". General information can be gained by using
```julia
ncinfo(filename)
```which gives an overview of the dimensions, variables and attributes stored in the file.
```julia
filename = "myfile.nc"
varname = "var1"
attribs = Dict("units" => "mm/d",
"data_min" => 0.0,
"data_max" => 87.0)
```Creating variables and files is done by using the nccreate command:
```julia
nccreate(filename, varname, "x1", collect(11:20), "t", 20, Dict("units"=>"s"), atts=attribs)
```This will create the variable called var1 in the file myfile.nc. The attributes defined in the Dict attribs are written to the file and are associated with the
newly created variable. The dimensions "x1" and "t" of the variable are called "x1" and "t" in this example. If the dimensions do not exist yet in the file,
they will be created. The dimension "x1" will be of length 10 and have the values 11..20, and the dimension "t" will have length 20 and the attribute "units"
with the value "s".Now we can write data to the file:
```julia
d = rand(10, 20)
ncwrite(d, filename, varname)
```The full documentation can be found [here][docs-dev-url]
An alternative interface for reading NetCDF files can be found here: https://github.com/Alexander-Barth/NCDatasets.jl
# DiskArray interface
As of version 0.9 we provide an interface to DiskArrays.jl, which lets you treat NetCDF variables as Julia AbstractArrays. Special methods for accessing, reading slices and reductions and broadcasting are implemented, so that working with the arrays should be efficient.
So the following returns a lazy AbstractArray container referencing the data in the variable.
```julia
v = NetCDF.open(filename, varname)
```## Credits
This package was originally started and is mostly maintained by Fabian Gans ([email protected]). The automatic C wrapper generator was contributed by Martijn Visser (https://github.com/visr). Many thanks to several people who contributed bug fixes and enhancements.
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
[docs-dev-url]: https://meggart.github.io/NetCDF.jl/dev[ci-img]: https://github.com/meggart/NetCDF.jl/workflows/CI/badge.svg
[ci-url]: https://github.com/meggart/NetCDF.jl/actions?query=workflow%3ACI