I'd like to export an sf object as a .kml file, with labels for each feature I'm interested in so I can view the data easily in Google Earth. I know you can click on the "info" button in Google Earth, but for hundreds of polygons, this isn't ideal.
For example, I'd like to label each polygon feature below using the column NAME. How can I modify the st_write call below to label the kml polygons so that they appear in the sidebar table of contents in Google Earth?
library(sf)
library(dplyr)
# sf includes this dataset
county_polygons <- st_read(system.file("shape/nc.shp", package="sf")) %>%
st_transform(4326)
st_write(county_polygons , "test.kml", driver = "kml")
Here's a picture showing the lack of labels in Google Earth when this is imported as a kml file:


sfis focused on spatial databases management, neither styles or labeling outside plot environment. A solution could be add alayer_optionsdeclaration from KML driver. I tried withNAMEandNameFieldwith no success - aldo_tapia