Xarray.Dataset or DataArray in UserTiffData
Currently, UserTiffData
serves as an entry point to the ZonalGen
class and does not accept an Xarray DataArray read in through any other method than rioxarray
. This can be circumvented by doing something like the following to add a "band" coordinate and index from a subsetted DataArray and was inspired by @arschultz.
# sub ds to dataarray
da_precip = ds_time_sub["PREC_ACC_NC"]
# create a new coord and use expand_dims to create an index
da_precip = da_precip.assign_coords(band=1)
da_precip = da_precip.expand_dims("band")
However, when this is passed to ZonalGen
like this:
zonal_gen = ZonalGen(
user_data=zonal_data,
zonal_engine="parallel",
zonal_writer="csv",
out_path=".",
file_prefix="test_zonal"
)
zonal = zonal_gen.calculate_zonal()
A "ValueError: All arrays must be of the same length" from pandas
is raised.