Example - Merge

[1]:
import rioxarray # for the extension to load
import xarray
from rioxarray.merge import merge_arrays
# Note: You can merge datasets with the merge_datasets method

%matplotlib inline

Load in xarray dataset

API reference:

[2]:
dem_test = "../../test/test_data/input/MODIS_ARRAY.nc"
with rioxarray.open_rasterio(dem_test) as rds:
    arrays = [
        rds.isel(x=slice(100), y=slice(100)),
        rds.isel(x=slice(100, 200), y=slice(100, 200)),
        rds.isel(x=slice(100), y=slice(100, 200)),
        rds.isel(x=slice(100, 200), y=slice(100)),
    ]
    merged = merge_arrays(arrays)
[3]:
rds.where(rds!=rds.nodata).plot();
../_images/examples_merge_4_0.png
[4]:
merged.where(merged!=merged.nodata).plot()
[4]:
<matplotlib.collections.QuadMesh at 0x7fb8d27c0908>
../_images/examples_merge_5_1.png