Description Usage Arguments Value See Also Examples
Transform a image raster to a data frame.
1 | image2data(x, background = "white", x_range = NULL, y_range = NULL)
|
x |
It could be a rasterly object or a raster image. |
background |
The background of image raster. |
x_range |
The range represents image width. |
y_range |
The range represents image height. |
a data.table
object
ggRasterly
1 2 3 4 5 6 7 8 9 10 11 12 13 | x <- rnorm(1000, mean = 10)
y <- rnorm(1000, mean = 20)
color <- sample(1:5, 1000, replace = TRUE)
rastObj <- data.frame(x = x, y = y, color = color) %>%
rasterly(mapping = aes(x = x, y = y, color = color)) %>%
rasterly_points()
p <- rasterly_build(rastObj)
dt <- image2data(p)
if(requireNamespace("ggplot2")) {
# Note that each point represents a single pixel in the image
ggplot2::ggplot(dt, mapping = aes(x = x, y = y)) +
ggplot2::geom_point(color = dt$color, size = 0.5)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.