get_local_ij {h3jsr}R Documentation

Get local i, j coordinates

Description

This function defines local i, j coordinates for an H3 destination cell relative to an H3 origin cell.

Usage

get_local_ij(origin = NULL, destination = NULL, simple = TRUE)

Arguments

origin

Character; 15-character cell index generated by H3. A vector of indexes can also be supplied.

destination

Character; 15-character cell index generated by H3. A vector of indexes can also be supplied.

simple

Logical; whether to include an unprojected sfc_POINT geometry column in the output object.

Value

If simple = TRUE, a matrix where each row contains the local i, j coordinates for the supplied destination indexes. If not, an sf object with origin and destination attributes, point geometry of the destination cell centers, and an undefined coordinate reference system.

Note

Examples

# Get local coordinates for a nearby cell
get_local_ij(origin = '86be8d12fffffff', destination = '86be8d127ffffff')

# Get local coordinates for a donut of nearby cells
destinations <- get_ring(h3_address = '86be8d12fffffff', ring_size = 2)
local_coords <- get_local_ij(origin = rep('86be8d12fffffff', length(destinations[[1]])),
                             destination = destinations[[1]],
                             simple = FALSE)

plot(local_coords['destination'], pch = 19) # note origin is (0,0)


[Package h3jsr version 1.3.1 Index]