Comments (2)
@adehecq windows have float offsets and dimension. They're primarily for use with GDAL. They must be rounded if you want integers that can be used to slice an array.
from rasterio.
@adehecq windows have float offsets and dimension. They're primarily for use with GDAL. They must be rounded if you want integers that can be used to slice an array.
Thanks @sgillies. Yes, I'm aware that windows have float offsets and dimension. Sorry if that was not clear, but what I meant is that the output is incorrect. The function returns a height of 3022.0000000000005 whereas it should be exactly 3022.
This is caused by floating precision. windows.from_bounds
uses transform.rowcol
underneath, at this line. In the example I gave above:
rows, cols = rio.transform.rowcol(transform, [left, right, right, left],[top, top, bottom, bottom],op=float,)
yields "rows = [0.533333333333303, 0.533333333333303, 3022.5333333333338, 3022.5333333333338]". Due to floating precision, the left term has 15 decimals and the right one 13. I don't know if there is a way to overcome this precision issue? Maybe by allowing a fixed number of decimals?
This floating precision issue has caused me a lot of troubles with many other rasters...
from rasterio.
Related Issues (20)
- Rasterio merge gives different results with different python versions HOT 2
- Overhaul test_plot.py
- Simplify rasterize() HOT 1
- Readthedocs stable build out of date HOT 2
- plot.show for (n,1) and (1,n) numpy arrays HOT 2
- Improve calculate_default_transform/aligned_target interaction HOT 5
- Rounding error in calculate_default_transform HOT 2
- Relax assumption that tiled dataset blocks be multiples of 16
- Documentation update: rasterio.io.DatasetReader.sample documentation says it returns array, not generator
- Add a rio create command
- Numpy 2 compatibility and the numpy C API HOT 4
- Sidecar support for the python opener HOT 1
- Testing on Windows HOT 6
- `merge.merge` will always print nodata warning for complex rasters HOT 1
- Memory leak with .read() HOT 31
- Import Error about GDAL HOT 1
- Python opener improvements needed
- Possibly misleading documentation leads setting `zs` value as `rpcs.height_off`
- rasterio WarpedVRT vs QGIS Warp tool
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 rasterio.