I am trying to convert raster to polygon using stars package as suggested in this and this. I have used the following code
library(raster)
library(stars)
library(sf)
library(magrittr)
#read raster
r1<-raster("raster_name.asc")
convert raster to polygon, dissolved neighboring same values
r.to.poly<-st_as_stars(r1) %>%
st_as_sf(merge = TRUE)
which is giving me the following error
Error in CPL_polygonize(file, mask_name, "GTiff", "Memory", "foo", options, : basic_string::_S_construct null not valid
How to solve this error?