6.6 Spatial vectorization
raster —> vector: as.point s()
, as.polygon()
= rast(system.file("raster/elev.tif", package = "spData"))
elev = terra::as.points(elev) |>
elev_point st_as_sf()
plot(elev_point["elev"])
= rast(system.file("raster/dem.tif", package = "spDataLarge"))
dem = terra::as.contour(dem) |>
cl st_as_sf()
plot(dem, axes = FALSE)
plot(cl, add = TRUE)
= rast(system.file("raster/grain.tif", package = "spData"))
grain = terra::as.polygons(grain) |>
grain_poly st_as_sf()
plot(grain_poly)
= terra::as.polygons(grain, dissolve = FALSE) |>
grain_poly st_as_sf()
plot(grain_poly)