Passing resampling
Without thinking I put resampling="bilinear" and got an error when I called .compute()
Traceback (most recent call last):
File "carajas.py", line 92, in <module>
band_medianNP = band_median.compute()
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/xarray/core/dataarray.py", line 899, in compute
return new.load(**kwargs)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/xarray/core/dataarray.py", line 873, in load
ds = self._to_temp_dataset().load(**kwargs)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/xarray/core/dataset.py", line 798, in load
evaluated_data = da.compute(*lazy_data.values(), **kwargs)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/base.py", line 565, in compute
results = schedule(dsk, keys, **kwargs)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/threaded.py", line 76, in get
results = get_async(
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/local.py", line 487, in get_async
raise_exception(exc, tb)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/local.py", line 317, in reraise
raise exc
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/local.py", line 222, in execute_task
result = _execute_task(task, data)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/core.py", line 121, in _execute_task
return func(*(_execute_task(a, cache) for a in args))
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/core.py", line 121, in <genexpr>
return func(*(_execute_task(a, cache) for a in args))
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/core.py", line 121, in _execute_task
return func(*(_execute_task(a, cache) for a in args))
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/optimization.py", line 963, in __call__
return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/core.py", line 151, in get
result = _execute_task(task, cache)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/dask/core.py", line 121, in _execute_task
return func(*(_execute_task(a, cache) for a in args))
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/stackstac/to_dask.py", line 151, in fetch_raster_window
data = reader.read(current_window)
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/stackstac/rio_reader.py", line 393, in read
reader = self.dataset
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/stackstac/rio_reader.py", line 389, in dataset
self._dataset = self._open()
File "/home/ubuntu/anaconda3/envs/richard/lib/python3.8/site-packages/stackstac/rio_reader.py", line 355, in _open
vrt = WarpedVRT(
File "rasterio/_warp.pyx", line 871, in rasterio._warp.WarpedVRTReaderBase.__init__
TypeError: an integer is required
so I presume you need to pass the integer from the enum? e.g. 1 in this case? Or I am not quite clear on what this keyword is expecting?
I think you need to pass the enum value from rasterio's Resampling enum
I am guessing the integer-resampling mapping is the same as rasterio. See the rasterio docs here: https://rasterio.readthedocs.io/en/latest/api/rasterio.enums.html#rasterio.enums.Resampling
I was on my phone before but yes, it should be a resampling enum https://github.com/gjoseph92/stackstac/blob/b652a07f9b2ae27235aea4db4ef0f1f594fd8941/stackstac/stack.py#L29
Yes, my guess too when testing. We should put this in an example so people see it obviously. Or be fancy and the common text terms could map back via a dictionary?
Or be fancy and the common text terms could map back via a dictionary?
This seems worthwhile. Quite easy to add something like
if isinstance(resampling, str):
try:
resampling = Resampling[resampling]
except KeyError:
raise ValueError(...) from None
Just curious, what's the point of raising the exception from None there? I would've assumed that would be identical to a bare raise ValueError
@kylebarron the from None just will give a shorter, cleaner traceback, eliminating the During handling of the above exception, another exception occurred message you'd otherwise see.
https://stefan.sofa-rockers.org/2020/10/28/raise-from/ https://stackoverflow.com/a/24752607
I'd love to take this on as a first issue with stackstac!
@szwiep sorry I missed your comment, please feel free to take this on, that would be much appreciated!
Hi all, finally put aside the time to get around to this! One question, how can I install from source/test my changes? I can't find documentation on this, so if you could point me in the right direction that'd be appreciated.