grid_to_polygon: Convert a grid of QuadKeys to square polygons

View source: R/grid_to_polygon.R

grid_to_polygonR Documentation

Convert a grid of QuadKeys to square polygons

Description

The main argument of this function, the grid of geographic coordinates (lat/long WG84) represents the upper-left corner of the QuadKey. To transform these coordinates into square polygons, the function supplements the grid by adding a row and column of tiles. These points introduce QuadKeys located at the border of the area using the internal function complete_grid_for_polygons(). The function builds the polygons using all the points of the grid. Note that it's possible to associate each QuadKey with its square polygon.

Usage

grid_to_polygon(data)

Arguments

data

A sf POINT data.frame with a quadkey and geometry column.

Value

A sf POLYGON data.frame with a quadkey column.

Examples

grid <- create_qk_grid(
  xmin = -59,
  xmax = -57,
  ymin = -35,
  ymax = -34,
  zoom = 11
)

grid_coords <- get_qk_coord(data = grid$data)

polygrid <- grid_to_polygon(grid_coords)
polygrid

quadkeyr documentation built on April 3, 2025, 8:52 p.m.