Convert (column, row) numbers to (x, y) coordinates for a given tile set.

tile_coords(data, id)

Arguments

data

a data frame containing columns named col and row. These contain column-row number pairs defining matrix cells in tile set id. See details.

id

character, name of map tile set ID. See stTiles.

Value

a data frame.

Details

This function converts column and row indices for an available map tile set matrix to coordinates that can be used in a Leaflet map. See stTiles for available tile sets.

data cannot contain columns named x or y, which are reserved for the column-appended output data frame.

Each tile set has a simple/non-geographical coordinate reference system (CRS). Respective coordinates are based on the dimensions of the source image used to generate each tile set. The same column and row pair will yield different map coordinates for different tile sets. Typical for matrices, columns are numbered increasing from left to right and rows increasing from top to bottom. The output of tile_coords() is a typical Cartesian coordinate system, increasing from left to right and bottom to top.

Examples

d <- data.frame(row = c(0, 3222, 6445), col = c(0, 4000, 8000))
tile_coords(d, "galaxy1")
#>    row  col   x         y
#> 1    0    0   0    0.0000
#> 2 3222 4000 125 -100.6875
#> 3 6445 8000 250 -201.4062