Skip to content
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

Padding and Croping doesn't end up same result #754

Closed
mohseniaref opened this issue Mar 5, 2024 · 2 comments
Closed

Padding and Croping doesn't end up same result #754

mohseniaref opened this issue Mar 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mohseniaref
Copy link

mohseniaref commented Mar 5, 2024

bounding_box=tr1.rio.bounds()
min_lon, min_lat, max_lon, max_lat = bounding_box
# Amount to add to each coordinate
degree_changea= 0.0002778181877900465*256
degree_changeo= 0.0002778181877900465*256
# New bounding box coordinates after adding 0.3 degrees
new_min_lon = min_lon - degree_changeo
new_min_lat = min_lat - degree_changea
new_max_lon = max_lon + degree_changeo
new_max_lat = max_lat + degree_changea
padded_box=(new_min_lon, new_min_lat, new_max_lon, new_max_lat)
padded_box=(new_min_lon, new_min_lat, new_max_lon, new_max_lat)
tr=tr1.rio.pad_box(*padded_box)
tr2=tr.rio.clip_box(*bounding_box)

tr.shape
(86, 7427, 8565)
tr1.shape
(86, 6913, 8051)
tr2.shape
(86, 6913, 8052)

Problem description

I expect after padding and croping to same bounding box ,I end up same array size which seems one pixel more!

Expected Output

tr1.shape
(86, 6913, 8051)
tr2.shape
(86, 6913, 8051)

Environment Information

rioxarray (0.15.0) deps:
rasterio: 1.3.9
xarray: 2023.12.0
GDAL: 3.6.4
GEOS: 3.11.1
PROJ: 9.0.1
PROJ DATA: /raid-manaslu/maref/Software/anaconda3/envs/sp/share/proj
GDAL DATA: /raid-manaslu/maref/Software/anaconda3/envs/sp/share/gdal

Other python deps:
scipy: 1.11.4
pyproj: 3.6.1

System:
python: 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:24:10) [GCC 9.4.0]
executable: /raid-manaslu/maref/Software/anaconda3/envs/sp/bin/python
machine: Linux-5.4.0-156-generic-x86_64-with-glibc2.31

$ conda list | grep -E "rasterio|xarray|gdal"


Details about conda and system ( conda info ):
$ conda info

@mohseniaref mohseniaref added the bug Something isn't working label Mar 5, 2024
@snowman2
Copy link
Member

snowman2 commented Mar 7, 2024

Related #155

@mohseniaref
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants