Skip to contents

Convert x, y coordinates to zones and subzones

Usage

dv_xy2subzone(x, y = NULL)

Arguments

x

numeric: the x coordinate

y

numeric: the y coordinate. If y is NULL, x will be treated as a grid index (see dv_index2xy)

Value

A tibble with columns zone and subzone

Examples

if (FALSE) {

## a bunch of random points on and around the court
idx <- round(runif(100, min = 1, max = 10000))

## convert to zones
zn <- dv_xy2subzone(x = idx)

## or, equivalently, convert the index to xy values first
zn <- cbind(zn, dv_index2xy(idx))

## plot
ggplot(zn, aes(x, y, colour = as.factor(zone), shape = subzone)) + geom_point(size = 3) +
  ggcourt(labels = NULL)

## the points shoud be coloured by zone
}