# Is there a convenient way to read netCDF datasets stored in nested groups when using NCDatasets.jl?

**URL:** <https://discourse.julialang.org/t/is-there-a-convenient-way-to-read-netcdf-datasets-stored-in-nested-groups-when-using-ncdatasets-jl/101589>\
**Category:** Geo\
**Tags:** question, netcdf\
**Created:** [July 13, 2023, 7:50pm UTC](https://discourse.julialang.org/t/is-there-a-convenient-way-to-read-netcdf-datasets-stored-in-nested-groups-when-using-ncdatasets-jl/101589 "2023-07-13T19:50:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haffner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haffner/32/35871_2.png) [@haffner](https://discourse.julialang.org/u/haffner)\
**Post date:** [July 13, 2023, 7:50pm UTC](https://discourse.julialang.org/t/is-there-a-convenient-way-to-read-netcdf-datasets-stored-in-nested-groups-when-using-ncdatasets-jl/101589/1 "2023-07-13T19:50:01Z")

</div>

Hi,

I’m relatively new to Julia and trying to use NCDatasets.jl to read satellite data stored in netCDF files. The data are stored in compound groups at the end of a path like this

`/BAND1_RADIANCE/STANDARD_MODE/GEODATA/latitude`

Through trial-and-error I learned I can get at the data by chaining `group()` functions together,

```julia
using NCDatasets
ds = Dataset("OMI-Aura_L1-OML1BRUG_2023m0710t0018-o100973_v0401-2023m0710t0603.nc", "r")
longitude = ds.group["BAND1_RADIANCE"].group["STANDARD_MODE"].group["GEODATA"]["longitude"]

```

But since I have do to this often for several dozen datasets, I’m wondering, is there’s an easier way than building this kind of statement manually for each of them?

I figure I could write a function like this,

`dataset = getdata(ds, "/artbitary/series/of/groups/to/dataset")`

but as I’m new to the language so I thought I’d join the discussion and ask. I’d appreciate any advice. Thanks.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 13, 2023, 10:56pm UTC](https://discourse.julialang.org/t/is-there-a-convenient-way-to-read-netcdf-datasets-stored-in-nested-groups-when-using-ncdatasets-jl/101589/2 "2023-07-13T22:56:35Z")

</div>

[RemoteS](https://github.com/GenericMappingTools/RemoteS.jl)?

---

<div class="post-metadata">

**Author:** ![haffner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haffner/32/35871_2.png) [@haffner](https://discourse.julialang.org/u/haffner)\
**Post date:** [July 13, 2023, 11:43pm UTC](https://discourse.julialang.org/t/is-there-a-convenient-way-to-read-netcdf-datasets-stored-in-nested-groups-when-using-ncdatasets-jl/101589/3 "2023-07-13T23:43:15Z")

</div>

Thanks, I’ll give that a shot. I’ve had success reading these data with GDAL before. The OMI instrument is very different than MODIS but it’s on Aura, sibling of Aqua and Terra. Would be nice to have a package fit for all three.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 14, 2023, 12:07am UTC](https://discourse.julialang.org/t/is-there-a-convenient-way-to-read-netcdf-datasets-stored-in-nested-groups-when-using-ncdatasets-jl/101589/4 "2023-07-14T00:07:22Z")

</div>

Yep, I only tested it with MODIS but if GDAL reads it, it should work too. But the MODIS _automatism’s_ may fail. Please open issues with reproducible cases if that’s the case.
