Skip to content

Instantly share code, notes, and snippets.

  w <- rnaturalearth::ne_countries(returnclass = "sf")
p <- geosphere::randomCoordinates(1e6)


## sp is FAST for point in polygon
system.time({
  pip1 <- sp::over(sp::SpatialPoints(p), as(sf::as_Spatial(sf::st_set_crs(w, NA)), "SpatialPolygons"))
})
#&gt; user system elapsed