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

Strange behaviour where crop is cropping too much #815

Open
asinghvi17 opened this issue Nov 6, 2024 · 3 comments
Open

Strange behaviour where crop is cropping too much #815

asinghvi17 opened this issue Nov 6, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@asinghvi17
Copy link
Collaborator

asinghvi17 commented Nov 6, 2024

using Rasters, RasterDataSources, ArchGDAL
using TiledIteration # easy splitting into tiles

dem = Raster(WorldClim{Climate}, :tmin, month = 1)
ras = read(view(dem, 1:10, 1:10))

ext = Extent(X=(lookup(ras, X)[2], lookup(ras, X)[7]), Y=(lookup(ras, Y)[7], lookup(ras, Y)[2]))

new_ras = zero(view(ras, ext))

tile_ranges = collect(TiledIteration.TileIterator(axes(ras), (5, 5)))
ras_tiles = (inds -> ras[inds...]).(tile_ranges)

sub_tiles = read.(view.(ras_tiles, (ext,)))

crop(new_ras, to = sub_tiles[1]) 

# here's the test
size(crop(new_ras, to = sub_tiles[1])) == size(sub_tiles[1]) # false?!
# it's wrong the other way too, in this case
size(crop(sub_tiles[1], to=new_ras)) == size(sub_tiles[1]) # false
@asinghvi17 asinghvi17 added the bug Something isn't working label Nov 6, 2024
@asinghvi17 asinghvi17 changed the title Strange behaviour where crop is not associative Strange behaviour where crop is cropping too much Nov 6, 2024
@asinghvi17
Copy link
Collaborator Author

asinghvi17 commented Nov 6, 2024

This might be the same problem as #751, but in a different place...

@rafaqz
Copy link
Owner

rafaqz commented Nov 6, 2024

Hmm I'll take a look. So much trouble getting extents right .

But what is new_ras ? I think your MWE is missing something

@asinghvi17
Copy link
Collaborator Author

Oops...edited, thanks. It's a zeroed out array with that Extent.

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