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

Can't select bands with descending index #641

Open
kadyb opened this issue Aug 16, 2023 · 6 comments
Open

Can't select bands with descending index #641

kadyb opened this issue Aug 16, 2023 · 6 comments

Comments

@kadyb
Copy link
Contributor

kadyb commented Aug 16, 2023

tif = system.file("tif/olinda_dem_utm25s.tif", package = "stars")
tif = c(tif, tif, tif, tif, tif)
x = read_stars(tif, proxy = TRUE, along = 3)
x[,,,1:3] # works
x[,,,3:1] # doesn't work
@edzer
Copy link
Member

edzer commented Aug 16, 2023

That indeed doesn't work. Would it be O.K. if it raises an error, or is this something that you need?

edzer added a commit that referenced this issue Aug 16, 2023
@kadyb
Copy link
Contributor Author

kadyb commented Aug 16, 2023

So I have a bigger issue. If we can't use descending indices in stars.proxy object then how can we use the st_rgb() function if the bands are in BGR order?

Edit1: In terra::plotRGB() we can specify the indices of each band.

Edit2: Probably best to use st_downsample() to load a low resolution raster into memory and then select RGB bands?

@edzer
Copy link
Member

edzer commented Aug 17, 2023

I see your point (and the st_rgb docs suggest this); FYI plot.stars() has an rgb argument that lets you specify band indices, like c(3,2,1) if they come as BGR.

edzer added a commit that referenced this issue Aug 17, 2023
@kadyb
Copy link
Contributor Author

kadyb commented Aug 17, 2023

Thanks! So I suggest 2 things:

  1. Add the information to the st_rgb() documentation like: Alternatively, you can use plot() function with the rgb argument to create a three-band composition.
  2. However, it might be worth leaving the error massage you made in the above commit, because maybe someone will also encounter this issue.
edzer added a commit that referenced this issue Aug 17, 2023
@edzer
Copy link
Member

edzer commented Aug 17, 2023

2: yes, but it didn't work, and seems much more complicated than I thought.

@kadyb
Copy link
Contributor Author

kadyb commented Aug 17, 2023

2: yes, but it didn't work, and seems much more complicated than I thought.

Okay, I didn't check. I suspect that e.g. x[,,,c(2, 4, 6)] can also be very problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants