Comments (6)
Ok, thanks a lot. When I read it with rioxarray or in QGIS or rastervision it works. I need to investigate this further. This should now make it possible for me to solve this and you can close the issue.
from torchgeo.
Hi @tgoelles! Congrats on your paper: https://doi.org/10.3389/frsen.2023.1156519. Our lab was recently in Austria for our winter school and I mentioned your group as one of our TorchGeo users.
from torchgeo.
I was able to reproduce this issue without using any sampler:
import rasterio
from torchgeo.datasets import BoundingBox, RasterDataset
path = "data/05_model_input/pre_processed_multiband.tif"
# Original data does not contain NaNs
f = rasterio.open(path)
ar = f.read()
print(ar)
print("NaNs:", (ar == f.nodata).sum())
# But it does when read by TorchGeo
ds = RasterDataset(path)
query = BoundingBox(558648, 559048, 5184009, 5184409, 0, 1e19)
sample = ds[query]
image = sample["image"]
print(image)
print("NaNs:", (image == f.nodata).sum().item())
Still investigating...
from torchgeo.
I suspect that there is something wrong with the file itself. TorchGeo just uses rasterio.merge.merge
to read the file. When I try to open the file without using TorchGeo:
import rasterio.merge
path = "data/05_model_input/pre_processed_multiband.tif"
rasterio.merge.merge([path])
I encounter the following error:
Traceback (most recent call last):
File "/Users/Adam/torchgeo/test2.py", line 4, in <module>
rasterio.merge.merge([path])
File "/Users/Adam/spack/var/spack/environments/default/.spack-env/view/lib/python3.11/site-packages/rasterio/merge.py", line 344, in merge
dst_window = windows.from_bounds(
^^^^^^^^^^^^^^^^^^^^
File "/Users/Adam/spack/var/spack/environments/default/.spack-env/view/lib/python3.11/site-packages/rasterio/windows.py", line 324, in from_bounds
raise WindowError("Bounds and transform are inconsistent")
rasterio.errors.WindowError: Bounds and transform are inconsistent
How was the file created?
from torchgeo.
Hi,
Hi @tgoelles! Congrats on your paper: https://doi.org/10.3389/frsen.2023.1156519. Our lab was recently in Austria for our winter school and I mentioned your group as one of our TorchGeo users.
Thanks! Also for your quick answer.
Here is how the geotiff is generated. Its generated with rioxarray:
def export_to_multiband_geotiff(master_dataset: xarray.Dataset, paramters: dict) -> str:
model_input_path = Path("/workspaces/avalanche/project/data/05_model_input")
save_path = model_input_path / f"pre_processed_multiband.tif"
bands_stack = xarray.concat([master_dataset["vv"], master_dataset["vh"], master_dataset["vvvh"]], dim="band")
bands_stack = bands_stack.assign_coords(band=("band", ["vv", "vh", "vvvh"]))
LOG.info(f"Saving multiband data to {save_path}")
bands_stack = bands_stack.rio.write_crs(master_dataset.rio.crs)
nodata_value = paramters["master_options"]["geotiff_nodata"]
LOG.info(f"Setting nodata value to {nodata_value}")
bands_stack.rio.write_nodata(nodata_value, inplace=True)
bands_stack.rio.to_raster(save_path)
return save_path.as_posix()
from torchgeo.
Could possibly be a bug in rioxarray. Might be worth reporting to them or to rasterio to see where the issue is. It doesn't seem to be a bug in TorchGeo though.
from torchgeo.
Related Issues (20)
- Sentinel 2 dataset can't see files downloaded from Copernicus Browser - filename doesn't fit regex HOT 1
- Errors & improvements in Metrics descriptions HOT 2
- Add a WMS Dataset HOT 2
- Switch from SMP to TorchSeg HOT 1
- Add plot method to IntersectionDataset HOT 1
- v0.5.2 missing PRs HOT 2
- Use ruff
- Add Inference Example HOT 1
- Switch coverage providers? HOT 1
- Auto download fails for FireRisk HOT 11
- Anomaly with RandomGrayScale tests HOT 2
- Add YAML formatter HOT 16
- Change documentation theme HOT 1
- CDL: cannot redownload additional years HOT 20
- Overrideable resample property for IntersectionDataset
- UnionDataset of two IntersectionDataset fails HOT 2
- Check if bbox of intersection is valid HOT 4
- Git clone and pip install results in 'Successfully installed UNKNOWN-0.0.0' HOT 10
- class_weights cannot be passed via config file as a tensor is expected HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchgeo.