-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Here's a brute force tidyfication of SGAT output
library(SGAT)
library(rworldmap)
library(rgdal)
library(rgeos)
prj <- "+proj=omerc +lonc=165 +lat_0=-22 +alpha=23 +k=0.99984 +x_0=0 +y_0=0 +no_uoff +gamma=23 +ellps=WGS84 +units=m +no_defs"
llprj <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
dp <- "."
fs <- list.files(dp, full.names = TRUE, pattern = "RData", ignore.case = TRUE)
library(tibble)
library(dplyr)
##
as_table_raster <- function(x) {
tibble(value = values(x), cell = seq(ncell(x))) %>% dplyr::filter(!is.na(value) & value > 0)
}
as_table_Pimage <- function(x) {
dplyr::bind_rows(lapply(seq_along(x), function(i) as_table_raster(x[i]) %>% mutate(gmt = as.POSIXct(x)[i])))
}
master <- raster(extent(-16800000, 12500000, -20300000, 19200000), res = 50000, crs = prj)
## loop over all files and save as table
for (j in seq_along(fs)) {
load(fs[j]);
label <- gsub(".rdata", "", tolower(basename(fs[j]))
tab <- as_table_Pimage(Pimage(fit, grid = master)) %>% mutate(id = label)
writeRDStab, file.path(".", sprintf("%s.rds", label)), compress = "xz")
})
allcells <- as_table_Pimage(im)It needs
- add to SQLite database rather than a list
- remove wasted pixels in as_table_raster by resurrecting the sparse cell stuff in tripEstimation (or SGAT?)
Metadata
Metadata
Assignees
Labels
No labels