1

I have spatial data from Earth (ice distribution) divided in two files (one for Arctic area and one for the Antarctic area). Time is the same, data variables are the same, only the spatial dim are different (longitude and latitude).

I'm struggling to use merge or concat to group then in on a unique dataset.

I tried different combinations to merge and concrete. For instance

ds = xarray.merge(objects=arrays, join="left", compat="override")
ds = xarray.concat(arrays, dim='time')

I also tried this solution: combining spatial netcdf files using xarray python

But in the end, I'm still not able to get the result I'm looking for: a unique dataset to display it on a globe (I'm using cartopy for this).

What are the best options today to do so ?

1 Answers1

0

Using the combine_first method could work pretty well if you only have two Datasets or DataArrays. you can just do da3 = da1.combine_first(da2), and this should work even if there are multiple dimensions which need to be combined. You may end up with NaNs if you don't have data for the full Cartesian product of the latitudes and longitudes in the final Dataset.

This method can work if you have more than two, you'll just need to repeatedly use combine_first to build up the full result piece by piece.

jmitt
  • 46
  • 3