# NOT RUN {
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)
x = x[,,,6] # a band with lower values in it
x[[1]][x[[1]] < 30] = NA # set lower values to NA
x[[1]] = x[[1]] < 100 # make the rest binary
x
(p = st_as_sf(x)) # removes NA areas
plot(p, axes = TRUE)
(p = st_as_sf(x, na.rm = FALSE)) # includes polygons with NA values
plot(p, axes = TRUE)
# }
Run the code above in your browser using DataLab