How can I find the nearest point on the coast from an ocean location?
There are public databases with the coastline in lon,lat format. You just need to find the point closest to your coordinates in that coastline. For that you need the formula of the distance between two lon,lat points on an ellipsoid. In this article you can find that and an idea of how to do it: 
Garcia-Castellanos, D., &amp; U. Lombardo, 2007. Poles of Inaccessibility: a calculation algorithm for the remotest places on Earth. Scott. Geogr. J., 123, 227-233. doi:10.1080/14702540801897809 
available here: https://web.archive.org/web/20140629230429/http://cuba.ija.csic.es/~danielgc/papers/Garcia-Castellanos,%20Lombardo,%202007,%20SGJ.pdf