Skip to content
New issue

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

update api_segments to handle empty segments #1155

Merged
merged 8 commits into from
Jun 14, 2024
4 changes: 3 additions & 1 deletion R/sits_segmentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ sits_slic <- function(data = NULL,
# Get valid centers
valid_centers <- slic[[2]][, 1] != 0 | slic[[2]][, 2] != 0
# Bind valid centers with segments table
v_obj <- cbind(v_obj, stats::na.omit(slic[[2]][valid_centers, ]))
v_obj <- cbind(
v_obj, matrix(stats::na.omit(slic[[2]][valid_centers, ]), ncol = 2)
)
# Rename columns
names(v_obj) <- c("supercells", "x", "y", "geometry")
# Get the extent of template raster
Expand Down
Loading