Skip to contents

Basic lookup function of coordinates on an icosahedral grid

Usage

locate(x, y, ...)

# S4 method for trigrid,matrix
locate(x, y, randomborder = FALSE, output = "ui")

# S4 method for trigrid,numeric
locate(x, y, ...)

# S4 method for trigrid,data.frame
locate(x, y, ...)

# S4 method for trigrid,sf
locate(x, y, ...)

# S4 method for trigrid,SpatialPoints
locate(x, y, ...)

# S4 method for trigrid,SpatialPointsDataFrame
locate(x, y, ...)

# S4 method for hexagrid,matrix
locate(x, y, output = "ui", randomborder = FALSE, forceNA = FALSE)

Arguments

x

(trigrid, hexagrid) Icosahedral grid object.

y

(matrix, data.frame, numeric or Spatial) Coordinates of individual points. Can be either a two-dimensional matrix of long-lat coordinates, a three-dimensional matrix of XYZ coordinates, or a set of points with class SpatialPoints or SpatialPointsDataFrame.

...

Arguments passed to class specific methods.

randomborder

(logical) Defaults to FALSE. If TRUE, then the points falling on vertices and edges will be randomly assigned, otherwise they will be kept as NAs.

output

(character) Either "ui" or "skeleton". "ui" returns the face names used in the user interface, while "skeleton" returns their indices used in back-end procedures.

forceNA

(logical) Suppressing the recursive lookup of points falling on subface boundaries.

Value

The function returns the cell names (as character) where the input coordinates fall.

Examples

# create a grid 
g <- trigrid(4)
# some random points
randomPoints<-rpsphere(4, output="polar")
# cells
locate(g, randomPoints)
#> [1] "F32"  "F178" "F211" "F50"