dlr-eoc / ukis-pysat

The ukis-pysat package provides generic classes and functions to query, access and process multi-spectral and SAR satellite images
Apache License 2.0
27 stars 8 forks source link

Dataset cannot be updated after warping image #48

Closed MWieland closed 4 years ago

MWieland commented 4 years ago

When trying to warp an image using Image().warp() I get the following error message:

  File "run_procs.py", line 119, in <module>
    num_threads=settings.general["num_threads"],
  File "D:\Workspaces\python\proc_s2_flood\procs\prepdata.py", line 468, in run
    img = prepdata.get_image()
  File "D:\Workspaces\python\proc_s2_flood\procs\prepdata.py", line 382, in get_image
    num_threads=self.num_threads)
  File "D:\Workspaces\python\proc_s2_flood\ukis_pysat\raster.py", line 206, in warp
    self.dataset = self.__update_dataset(self.dataset.meta).open()
  File "C:\Users\wiel_mc\AppData\Local\conda\conda\envs\pysatenv36new\lib\site-packages\rasterio\env.py", line 386, in wrapper
    return f(*args, **kwds)
  File "C:\Users\wiel_mc\AppData\Local\conda\conda\envs\pysatenv36new\lib\site-packages\rasterio\io.py", line 132, in open
    writer = get_writer_for_driver(driver)
  File "C:\Users\wiel_mc\AppData\Local\conda\conda\envs\pysatenv36new\lib\site-packages\rasterio\io.py", line 185, in get_writer_for_driver
    raise ValueError("'driver' is required to write dataset.")
ValueError: 'driver' is required to write dataset.

This seems to be related to updating the dataset and may also occur when trying to run other methods that modify the dataset (e.g. subset) - I haven't tested this though.

Running ukis-pysat on Win 7 with Python 3.6.

fwfichtner commented 4 years ago

Can you create a minimal example to reproduce?

MWieland commented 4 years ago

The problem seems to occur when using an image that is not GeoTIFF (hence the tests passed successfully). Tried the following with a Sentinel-2 .jp2 image band and it fails with above error message.

from ukis_pysat.raster import Image

file = "D:/tmp/test/T32UPU_20200413T100549_B01.jp2"

img = Image(data=file, dimorder="last")
img.warp(resampling_method=0, resolution=10, dst_crs="EPSG:32632", num_threads=4)

Will send you an example image per email (sorry but I cant access the network drives at the moment).