From a973c8f62ef9f86a39c946dbee505c465dae3acc Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Mon, 12 Feb 2024 20:18:30 -0800 Subject: [PATCH] gpkg_tables: add error handling for terra::vect() with a non-spatial fallback --- R/gpkg-util.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/gpkg-util.R b/R/gpkg-util.R index de9cdc7..467cdbb 100644 --- a/R/gpkg-util.R +++ b/R/gpkg-util.R @@ -28,7 +28,14 @@ gpkg_tables.geopackage <- function(x, collect = FALSE, pragma = FALSE) { unlist(lapply(names(y), function(z) { switch(z, "2d-gridded-coverage" = { sapply(y[[z]]$table_name, function(i) terra::rast(src, i)) }, - "features" = { sapply(y[[z]]$table_name, function(i) terra::vect(src, proxy = !collect, layer = i)) }, + "features" = { sapply(y[[z]]$table_name, function(i) { + res <- try(terra::vect(src, proxy = !collect, layer = i), silent = TRUE) + if (inherits(res, 'try-error')) { + message(i, " : ", res[1]) + res <- .LAZY.FUN(xx, table_name = i) + } + res + }) }, "attributes" = { sapply(y[[z]]$table_name, function(i) list(.LAZY.FUN(xx, table_name = i))) }) }), recursive = FALSE) }