coords_to_position {hilbert}R Documentation

Convert Coordinates to Grid Positions

Description

Convert Coordinates to Grid Positions

Usage

coords_to_position(x, ..., n = 10L, extent = NULL)

## S3 method for class 'data.frame'
coords_to_position(x, ..., n, extent, coords = c(1, 2), attach = TRUE)

## S3 method for class 'matrix'
coords_to_position(x, ..., n, extent, coords = c(1, 2), attach = TRUE)

## S3 method for class 'numeric'
coords_to_position(x, y, ..., n, extent)

## S3 method for class 'double'
coords_to_position(x, y, ..., n, extent)

## S3 method for class 'integer'
coords_to_position(x, y, ..., n, extent)

coords_to_position64(x, ..., n = 10L, extent = NULL)

## S3 method for class 'data.frame'
coords_to_position64(x, ..., n, extent, coords = c(1, 2), attach = TRUE)

## S3 method for class 'matrix'
coords_to_position64(x, ..., n, extent, coords = c(1, 2), attach = TRUE)

## S3 method for class 'numeric'
coords_to_position64(x, y, ..., n, extent)

## S3 method for class 'double'
coords_to_position64(x, y, ..., n, extent)

## S3 method for class 'integer'
coords_to_position64(x, y, ..., n, extent)

Arguments

x

One of: Numeric vector, data.frame, or matrix. If a numeric vector, then it corresponds to X coordinates.

...

Unused.

n

Exponent to the dimensions of the underlying grid. The Hilbert Curve indices are based on a ⁠2^n x 2^n⁠ grid. This number must be less than 15 due to the 32-bit implementation of R.

extent

Named vector with names xmax, xmin, ymax, ymin. Corresponds to the bounding box of the given coordinates. If extent is NULL, then the bounding box is found from the given coordinates.

coords

Column names or indices of a data.frame/matrix that contain the coordinates.

attach

If TRUE, adds the position as new columns to the given data.frame/matrix. This will replace the coordinate columns.

y

Numeric vector corresponding to Y coordinates.

Value

A data.frame containing the positions as integer columns x and y, or the original object (data.frame or matrix) with the coordinates replaced with the grid positions. When n is greater than 15, the positions are of type bit64::integer64.


[Package hilbert version 0.2.1 Index]