# NOT RUN {
# Retrieve all the tiles
s2tiles <- s2_tiles()
# Extract a subset of all the tiles
httr::GET(
"https://raw.githubusercontent.com/ranghetti/sen2r/devel/utils/vector/ch_bound.rds",
httr::write_disk(ch_path <- tempfile())
)
ch <- readRDS(ch_path)
s2tiles_ch <- s2tiles[suppressMessages(sf::st_intersects(ch, s2tiles))[[1]],]
s2_coords <- sf::st_coordinates(suppressWarnings(sf::st_centroid(s2tiles_ch)))
# Show the tiles
plot(s2tiles_ch$geometry, border = "blue")
plot(ch, border = "red", add = TRUE)
text(s2_coords[,1], s2_coords[,2], s2tiles_ch$tile_id, col = "blue", cex = .75)
# Use function tiles_intersects() to exclude unuseful tiles.
# }
Run the code above in your browser using DataLab