-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider array band count when writing Image #41
Comments
OT: Please be aware that you are quoting an old version of I also don't quite understand what you're doing, with rasterio.open(
destination,
"w",
driver="GTiff",
width=ndvi_arr.shape[-1],
height=ndvi_arr.shape[-2],
count=1,
dtype=np.float32,
transform=self.transform,
) as dst:
dst.write(ndvi_arr, indexes=1) |
Just edited the above comment. Should be |
The dataset is not the dataset you're looking for and this all becomes very confusing then. But I agree that it is very inviting to do something like that. |
I totally agree with that. So from a user's perspective we would call something like this: img = Image(array=myarray, crs=mycrs, transform=mytransform, dimorder="first") This would be more meaningful, less confusing and more flexible (I like the link to easily go from GDAL to ukis-pysat). |
Currently write_to_file() takes width and height from the Image array but its band number (count) from the dataset.
In case one initializes an Image() from an existing dataset and an array it may happen that the wrong band number is used internally to write to file. Take for example the case where someone computes a simple NVDI from a multi-band Image() and wants to write the result (a single-band image) back to file.
This would result in an error upon writing the array to file, because img band number != ndvi band number.
The following could be a possible solution to account for this:
The text was updated successfully, but these errors were encountered: