Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
method: str or callable, optional
See rasterio docs.
parse_coordinates: bool, optional
If False, it will disable loading spatial coordinates.
Returns
-------
:obj:`xarray.DataArray`:
The geospatially merged data.
"""
input_kwargs = dict(
bounds=bounds, res=res, nodata=nodata, precision=precision, method=method
)
merged_data, merged_transform = _rio_merge(
[RasterioDatasetDuck(dataarray) for dataarray in dataarrays],
**{key: val for key, val in input_kwargs.items() if val is not None},
)
merged_shape = merged_data.shape
representative_array = dataarrays[0]
if parse_coordinates:
coords = _make_coords(
representative_array, merged_transform, merged_shape[-1], merged_shape[-2],
)
else:
coords = _get_nonspatial_coords(representative_array)
out_attrs = representative_array.attrs
xda = DataArray(
name=dataarrays[0].name,
data=merged_data,
coords=coords,