Skip to content
SOISOS
  • FOOD
  • STATISTICS
  • PROGRAMMING
    • Python
    • Rust
    • Oracle
  • PHILOSOPHY
Home » How to access metadata using NetCDF4 python package
Posted inPython SOFTWARE

How to access metadata using NetCDF4 python package

Posted by By sunny.bak February 1, 2024

import netCDF4 as ncfn = ‘/path/to/file.nc4’
ds = nc.Dataset(fn)

# import Dataset from netCDF4
from netCDF4 import Dataset

# open nc file and save to nc
ds = Dataset('myfile.nc')

# print all metadata
print(ds)

# print metadata in key and value
print(ds.__dict__)

# print a specific key value
print(ds.__dict__['creator']

# print dimensions
print(ds.dimensions) or 
for dim in ds.dimensions.values():
    print(dim)

# print variable names only
print(ds.variables.keys())

# print crs
crs = nc.variables['crs']
Tags:
datasetmetadatanetcdf filenetcdf4pythonvariables
Last updated on February 1, 2024
sunny.bak
Love all things essential to happiness and contentment and Data science, Programming, Statistics
View All Posts

Post navigation

Previous Post
Metadata guideline for crs in netcdf files
Next Post
Creating htmlwidget in RStudio
Copyright 2025 — SOISOS. All rights reserved. Sinatra WordPress Theme
Scroll to Top