I use the code below to calculate the geometric's centroid:
libaray(sf)
city_map <- st_read("~\\city.shp")
city_map<-sf::st_transform(city_map,crs=4326)
city_center <-city_map %>%
sf::st_centroid()
But I always get this error:
Error in wk_handle.wk_wkb(wkb, s2_geography_writer(oriented = oriented, :
Loop 0 is not valid: Non-empty, non-full loops must have at least 3 vertices
I would really appreciate your help on this matter Many thanks