The coastal environment is a natural and economic resource of extraordinary value, but it is constantly modifying and susceptible to climate change, human activities and natural hazards. Remote sensing techniques have proved to be excellent for coastal area monitoring, but the main issue is to detect the borderline between water bodies (ocean, sea, lake or river) and land. This research aims to define a rapid and accurate methodological approach, based on the k-means algorithm, to classify the remotely sensed images in an unsupervised way to distinguish water body pixels and detect coastline. Landsat 8 Operational Land Imager (OLI) multispectral satellite images were considered. The proposal requires applying the k-means algorithm only to the most appropriate multispectral bands, rather than using the entire dataset. In fact, by using only suitable bands to detect the differences between water and no-water (vegetation and bare soil), more accurate results were obtained. For this scope, a new index based on the optimum index factor (OIF) was applied to identify the three best-performing bands for the purpose. The direct comparison between the automatically extracted coastline and the manually digitized one was used to evaluate the product accuracy. The results were very satisfactory and the combination involving bands B2 (blue), B5 (near infrared), and B6 (short-wave infrared-1) provided the best performance.