R/idfland.R

Defines functions idfland

Documented in idfland

#' @title idfland
#' @description This function allows you to identify location in which land or ocean.
#' @param lon Input the longitude.
#' @param lat Input the latitude.
#' @export
#' @import sf
#' @import spData
#' @examples
#' idfland(22,-5)



idfland<-function(lon,lat){

loc<-data.frame(lon=lon,lat=lat)
pts <- st_as_sf(loc, coords=1:2, crs=4326)
wd <- read_sf(system.file("shapes/world.gpkg", package="spData"))
loc$ps<-!is.na(as.numeric(st_intersects(pts, wd)))
loc$iden<-ifelse(loc$ps=="TRUE","land","ocean")
loc2<-loc$iden

return(loc2)

}

Try the oceanic package in your browser

Any scripts or data that you put into this service are public.

oceanic documentation built on April 3, 2025, 7:35 p.m.