Skip to content

Commit

Permalink
Merge pull request #185 from inbo/ws_fix_geom_speedup
Browse files Browse the repository at this point in the history
read_watersurfaces(): make fix_geom handling a bit more efficient
  • Loading branch information
florisvdh authored Aug 8, 2024
2 parents 5291921 + 1ebd40d commit 1f843ea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/read_habitatdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,13 @@ read_watersurfaces <-
}

if (fix_geom) {
n_invalid <- sum(
!st_is_valid(watersurfaces) | is.na(st_is_valid(watersurfaces))
)
validities <- st_is_valid(watersurfaces)
n_invalid <- sum(!validities | is.na(validities))
if (n_invalid > 0) {
watersurfaces <- st_make_valid(watersurfaces)
message("Fixed ", n_invalid, " invalid or corrupt geometries.")
} else {
message("No invalid or corrupt geometries found.")
}
}

Expand Down

0 comments on commit 1f843ea

Please sign in to comment.