Verify if a point is Land or Water in Google Maps

Inspired by this question on StackOverflow “Verify if a point is Land or Water in Google Maps” I decided to see if the question was solvable quickly and easily. This being the API economy.. surely Google has an API to solve this question? It does… in the form of Google Elevation API. Here are the end results:

elevation api to detect land vs water

elevation api to detect land vs water

 

Note the hexagons pretty much stay on land even though a rectangular perimeter is defined that goes partly over water. In this case I did a quick check from within Google Maps itself and the minimum elevation on land was about 8-9m so that was my threshold. Anything below 8m is considered sea. The code is mostly derivated from google documentation and stack overflow, but here’s the full gist:

https://gist.github.com/dvas0004/fd541a0502528ebfb825