title: Error in `dplyr::mutate()` when I use the code from GitHub
body: <pre><code>knitr::opts_chunk$set(fig.width=14, fig.height=8, echo=TRUE, eval=TRUE, cache=FALSE,
                        warning=FALSE, message=FALSE,
                        cache.lazy = FALSE)
  
  ## Load packages
  library(tidyverse, quietly = TRUE)
  library(ggrepel, quietly = TRUE)
  library(knitr, quietly = TRUE)
  library(here, quietly = TRUE)
  library(ggplot2, quietly = TRUE)
  library(tidyverse, quietly = TRUE)
  library(ggstar, quietly = TRUE)
  library(omd, quietly = TRUE)
  source(&quot;01-helpers.R&quot;)
  figdir = &quot;~/Dropbox/Apps/Overleaf/OMD/figures&quot; 
  </code></pre>
  <p>There is no error and it shows the path of the file <code>here() starts at C:/Users/jerry/Desktop/Code/main</code>, and a</p>
  <pre><code>── Conflicts ────────────────────────────── tidyverse_conflicts() ──
  x dplyr::filter() masks stats::filter()
  x dplyr::lag()    masks stats::lag()
  </code></pre>
  <p>Here's the box we'll focus on.</p>
  <pre><code>lat = 19.8968
  lon = -155.5828
  boxsize = 40
  lonrange = lon + c(-1,1) * boxsize
  latrange = lat + c(-1,1) * boxsize
  latrange = pmin(latrange, 48.25) 
  latrange = pmax(latrange, -20.5) 
  restrictbox &lt;- . %&gt;% filter(lat &gt; latrange[1],
                              lat &lt; latrange[2],
                              lon &gt; lonrange[1],
                              lon &lt; lonrange[2])
  world &lt;- rnaturalearth::ne_countries(scale = &quot;medium&quot;, returnclass = &quot;sf&quot;)
  </code></pre>
  <h2>Load data</h2>
  <p>First, we load Darwin data (from <a href="https://github.com/brorfred/ocean_clustering/" rel="nofollow noreferrer">https://github.com/brorfred/ocean_clustering/</a>)
  at 2-degree resolution.</p>
  <pre><code>ddat = read.csv(file.path(datadir_orig, &quot;tabulated_darwin_montly_clim_090_180_ver_0_2_6.csv&quot;)) %&gt;% as_tibble()
  rdat = read.csv(file.path(datadir_orig, &quot;tabulated_geospatial_montly_clim_090_180_ver_0_2_5.csv&quot;)) %&gt;% as_tibble()
  </code></pre>
  <h2>Gather data</h2>
  <p>All twelve month's worth of data is first gathered into two list objects.</p>
  <pre><code>## Making common set of lon, lats.
  alldat_list = alldat_list %&gt;%
    purrr::map(. %&gt;%
               remove_landlock() %&gt;%
               dplyr::select(lon, lat, val) %&gt;% 
               complete_rectangle() %&gt;%
               dplyr::arrange(lon, lat))
  </code></pre>
  <p>Here it reports the error:</p>
  <pre><code>Error in `dplyr::mutate()`:
  ! Problem while computing `land =
    mark_land(lon, lat, overreact = TRUE, buffer_in_km
    = 250)`.
  Caused by error in `s2_geography_from_wkb()`:
  ! Evaluation error: Found 1 feature with invalid spherical geometry.
  [1] Loop 120 is not valid: Edge 743 crosses edge 998.
  Backtrace:
    1. alldat_list %&gt;% ...
   29. base::stop(`&lt;Rcpp::v_&gt;`)
   Error in dplyr::mutate(., land = mark_land(lon, lat, overreact = TRUE, : 
  
  Caused by error in `s2_geography_from_wkb()`:
  ! Evaluation error: Found 1 feature with invalid spherical geometry.
  [1] Loop 120 is not valid: Edge 743 crosses edge 998.
  </code></pre>
  <p>How to deal with it?</p>