Skip to content

Commit

Permalink
address #375 (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
goergen95 authored Oct 1, 2024
1 parent 840cbac commit 9ba6084
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- fixes `portfolio_wide()` throwing an error when single assets with `NULL`
values are present
- `calc_mangroves_area()` returned NULL if invalid geometries were encountered
Now it tries to repair geometries and return the area of valid geometries (#375)

# mapme.biodiversity 0.9.1

Expand Down
5 changes: 4 additions & 1 deletion R/calc_mangroves_area.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ calc_mangroves_area <- function() {
}

results <- purrr::map(1:length(gmw), function(j) {
intersected <- suppressWarnings(st_intersection(gmw[[j]], x))
mangroves <- st_make_valid(gmw[[j]])
intersected <- suppressWarnings(st_intersection(mangroves, x))
intersected <- st_make_valid(intersected)
intersected <- intersected[st_is_valid(intersected), ]
area <- sum(as.numeric(st_area(intersected)), na.rm = TRUE) / 10000
year <- strsplit(names(gmw[j]), "_|.gpkg")[[1]][3]

Expand Down

0 comments on commit 9ba6084

Please sign in to comment.