We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Here's a stab at getting a "neighbourhood" of values from the bins.
## extract bin values with distance radius and within a negative time window (in days) bin_extract <- function(x, radius = 50000, days = 8) { ## input vectors of lon, lat, dates, lab for query-stations lon <- x[[1]] lat <- x[[2]] dates <- as.Date(x[[3]]) lab <- as.character(x[[4]]) l <- vector("list", length(lon)) for (i in seq_along(dates)) { ll <- vector("list", days) for (j in seq_len(days)) { rt <- bin_extract1(lon[i], lat[i], dates[i] - j + 1, radius) if (!is.null(rt)) rt$distance_t <- unclass(as.Date(dates[i])) - unclass(as.Date(rt$date)) ll[[j]] <- rt } #browser() st <- do.call(rbind, ll) if (!is.null(st)) st$label <- lab[i] l[[i]] <- st } do.call(rbind, l) } bin_extract1 <- function(lon, lat, date, radius) { ex <- extent(lon + c(-1, 1) * (radius / (1852 * 60)) * 1/cos(lat * pi/180), lat + c(-1, 1) * (radius / (1852 * 60))) init <- croc::initbin(4320) bins <- raadtools:::.crop_init(init, ex) out <- read_oc_sochla(date, bins = tibble::tibble(bin_num = bins)) if (nrow(out) < 1) return(NULL) #browser() xy <- croc::bin2lonlat(out$bin_num, 4320) out$distance_m <- traipse::track_distance_to(xy[,1], xy[,2], rep(lon, nrow(xy)), rep(lat, nrow(xy))) out[c("blon", "blat")] <- xy out } bin_extract(kax[1, c("lon", "lat", "date", "Trawl Number")])
The text was updated successfully, but these errors were encountered:
There's a lot of repeat read over days, so
Sorry, something went wrong.
No branches or pull requests
Here's a stab at getting a "neighbourhood" of values from the bins.
The text was updated successfully, but these errors were encountered: