I am using the script below to make to make interactive leaflet map. However, the contours have sharp changes and are not smooth and round. How can I edit this code to achieve that?
The data and code is from this link: https://adelieresources.com/2022/10/making-contour-maps-in-r/
Sta_den <- eks::st_kde(df) # calculate density
contours <- eks::st_get_contour(Sta_den, cont=c(20,40,60,80)) %>%
mutate(value=as.numeric(levels(contlabel)))
pal <- colorBin("YlOrRd", contours$contlabel, bins = c(20,40,60,80), reverse = TRUE)
pal_fun <- leaflet::colorQuantile("YlOrRd", NULL, n = 4)
p_popup <- paste("Density", as.numeric(levels(contours$contlabel)), "%")
leaflet::leaflet(contours) %>%
leaflet::addTiles() %>% # OpenStreetMap by default
leaflet::addPolygons(fillColor = ~pal_fun(as.numeric(contlabel)),
popup = p_popup, weight=2)%>%
leaflet::addLegend(pal = pal, values = ~contlabel, group = "circles", position = "bottomleft",title="Density quantile")