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

Special bindings for stars data structures #1200

Open
cpsievert opened this issue Feb 20, 2018 · 0 comments
Open

Special bindings for stars data structures #1200

cpsievert opened this issue Feb 20, 2018 · 0 comments
Labels

Comments

@cpsievert
Copy link
Contributor

@cpsievert cpsievert commented Feb 20, 2018

A good start would be to replicate the plot.stars() method (from https://github.com/r-spatial/stars)

library(stars)
etm <- st_stars(system.file("tif/L7_ETMs.tif", package = "stars"))
plot(etm)

screen shot 2018-02-20 at 4 00 19 pm

So plot_ly(etm) would do something similar to this (automatically)

library(sf)
etm <- st_transform(etm, 3857)
band <- st_dimensions(etm)[["band"]]
n <- band$to - band$from + 1
ann <- list(x = 0.5, y = 1, yanchor = "bottom", xanchor = "middle", xref = "paper", yref = "paper", showarrow = FALSE)
plots <- lapply(seq_len(n), function(i) {
  z <- t(etm[[1]][,,i])
  ann$text <- paste(names(etm), i)
  plot_ly(z = z[seq.int(nrow(z), 1), ]) %>%
    layout(annotations = ann) %>%
    colorbar(title = i)
})
subplot(plots, nrows = 2, titleX = TRUE, shareX = TRUE, shareY = TRUE)

https://plot.ly/~cpsievert/23012.png

cc @jackparmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.