satellogic / telluric

telluric is a Python library to manage vector and raster geospatial data in an interactive and easy way
MIT License
87 stars 18 forks source link

Use non-zero precision for window calculations #311

Closed drnextgis closed 3 years ago

drnextgis commented 3 years ago

Before:

In [1]: from rasterio.windows import Window                                                                                                                   

In [2]: w1 = Window(col_off=1337.90059880239, row_off=1626.659092546026, width=100, height=100)                                                               

In [3]: w2 = Window(col_off=1337.5005988023904, row_off=1626.0257592126945, width=100, height=100)                                                            

In [4]: w1 = w1.round_offsets(pixel_precision=0)                                                                                                              

In [5]: w2 = w2.round_offsets(pixel_precision=0)                                                                                                              

In [6]: w1.row_off, w2.row_off                                                                                                                                
Out[6]: (1627, 1626)

After:

In [7]: w1 = Window(col_off=1337.90059880239, row_off=1626.659092546026, width=100, height=100)                                                               

In [8]: w2 = Window(col_off=1337.5005988023904, row_off=1626.0257592126945, width=100, height=100)                                                            

In [9]: w1 = w1.round_offsets(pixel_precision=3)                                                                                                              

In [10]: w2 = w2.round_offsets(pixel_precision=3)                                                                                                             

In [11]: w1.row_off, w2.row_off                                                                                                                               
Out[11]: (1626, 1626)