-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
At
stackstac/stackstac/to_dask.py
Line 178 in 4029a68
| return np.broadcast_to(np.nan, (1, 1) + windows.shape(current_window)) |
fetch_raster_window will fill with NaN, which can result in data.dtype not matching data.compute().dtype. It should use the user-provided fill_value instead.
A non-minimal reproducer, from microsoft/PlanetaryComputer#17
import numpy as np
import xarray as xr
import rasterio.features
import stackstac
import pystac_client
import pystac
import planetary_computer
from rasterio.enums import Resampling
import rioxarray
import dask
from dask_gateway import GatewayCluster
catalog = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")
aoi = {
"type": "Polygon",
"coordinates": [
[
[-100, 30],
[-100, 66],
[-47, 66],
[-47, 30],
[-100, 30]
]
],
}
search = catalog.search(
#collections=["cop-dem-glo-90"], intersects=aoi
collections=["alos-dem"], intersects=aoi
)
items = list(search.get_items())
signed_items = [planetary_computer.sign(item).to_dict() for item in items]
a = stackstac.stack(
signed_items,
assets=["data"],
chunksize=512,
resolution=1000,
epsg=32198,
resampling=Resampling.average,
dtype="int16",
fill_value=0,
# bounds=[-2009488, -715776, 1401061, 2597757],
).drop('band').squeeze()
# mosaic = stackstac.mosaic(data)
# mosaic
assert a.dtype == a[0, :10, :10].compute().dtypeI'll make a PR.
Metadata
Metadata
Assignees
Labels
No labels