convert polygon to raster
Examples
df <- data.frame(x = 1:5, y = c(1, 4, 4, 3, 1))
d <- data.frame(id = 1, name = "polygon_1")
my_polygon <- terra::vect(as.matrix(df), type = "polygons", atts = d)
polygon_to_raster(my_polygon)
#> $raster
#> class : SpatRaster
#> dimensions : 3, 4, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 1, 5, 1, 4 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : poly_i
#> min value : 1
#> max value : 1
#>
#> $ID_vector
#> 1
#> 1
#>