xy_to_gridcells: Convert between Web Mercator Coordinates and Grid Cell...

View source: R/clusters.R

xy_to_gridcellsR Documentation

Convert between Web Mercator Coordinates and Grid Cell Indices

Description

Converts between projected Web Mercator (EPSG:3857) coordinates in meters and quadtree grid cell indices. The conversion back from grid cell indices returns the coordinates of the lower left corner of the cell.

Usage

xy_to_gridcells(xy, zoom = 0L)

gridcells_to_xy(xyz)

Arguments

xy

Rows of Web Mercator coordinates in meters (x, y).

zoom

Zoom level(s) of the quadtree dividing the Earth into a square 2^{zoom} grid.

xyz

Rows of zero-based, integer grid cell indices (x, y, zoom).

Examples

xy <- cbind(x = 0, y = 0)
xyz <- xy_to_gridcells(xy, zoom = 1)
gridcells_to_xy(xyz)
xyz <- xy_to_gridcells(xy, zoom = 0)
gridcells_to_xy(xyz)

falling-fruit/fruitr documentation built on Dec. 21, 2024, 8:32 p.m.