# NOT RUN {
# Sample data
dat = data.frame(
x = c(1, 1, -1, 3, 3),
y = c(0, -3, 2, -2, 0),
ex = c(0.5, 2, 2, 0.3, 0.6),
ey = c(0.5, 0.2, 1, 1, 0.3),
stringsAsFactors = FALSE
)
dat = st_as_sf(dat, coords = c("x", "y"))
dat
# Plot 1
plot(dat %>% st_geometry, graticule = TRUE, axes = TRUE, main = "Input")
text(dat %>% st_coordinates, as.character(1:nrow(dat)), pos = 2)
# Calculate ellipses
el = st_ellipse(pnt = dat, ex = dat$ex, ey = dat$ey)
# Plot 2
plot(el, graticule = TRUE, axes = TRUE, main = "Output")
plot(dat %>% st_geometry, pch = 3, add = TRUE)
text(dat %>% st_coordinates, as.character(1:nrow(dat)), pos = 2)
# }
Run the code above in your browser using DataLab