Open mdsumner opened 1 year ago
get the boundary something like this, so we can trim which granules to make an image from
get_geol_boundary <- function(file) {
lon <- vapour::vapour_read_raster(hdfL1B(file, "Longitude"), native = T)
lon <- matrix(lon[[1]], 406, byrow = TRUE)
ll <- c(lon[1, ], lon[-1,ncol(lon)], rev(lon[nrow(lon), ]), rev(lon[-c(1, nrow(lon)),1]))
lat <- vapour::vapour_read_raster(hdfL1B(file, "Latitude"), native = T)
lat <- matrix(lat[[1]], 406, byrow = TRUE)
lt <- c(lat[1, ], lat[-1,ncol(lat)], rev(lat[nrow(lat), ]), rev(lat[-c(1, nrow(lat)),1]))
cbind(ll, lt)
}
determine intersections with region of interest thus:
l <- list()
for (i in seq_along(f)) {
bb <- reproj::reproj_xy(get_geol_boundary(f[i]), prj, source = "OGC:CRS84")
wk <- wk::wk_polygon(wk::xy(bb[,1], bb[,2]))
int <- geos::geos_intersection(wk, p)
if (!geos::geos_is_empty(int)) {
l <- c(l, list(int))
}
}
lot in progress
and somewhat relevant to: https://github.com/AustralianAntarcticDivision/blueant/issues/12