File Exchange

image thumbnail

land_or_ocean.m

version 1.0.0.0 (42.4 KB) by Dan Chavas
Determine if input points (lat/lon) are over land or ocean

6 Downloads

Updated 27 Jan 2014

View License

File takes as input vector of points (lat/lon) and coastal resolution and returns vector of indicators for whether these points are over land or ocean. Makes geographic plot too, if desired.

Primary code was given in a response to a question by Brett Shoelson in Feb 2011: http://www.mathworks.com/matlabcentral/answers/1065-determining-whether-a-point-on-earth-given-latitude-and-longitude-is-on-land-or-ocean
As far as I can tell, this code has not been put into a function file for public use.

Comments and Ratings (2)

LR

Great function!
I found some of locations that produce the following error message:

---------------------------------------
Error using delaunayTriangulation/pointLocation
The triangulation is empty.

Error in inpolyfast (line 20)
si = dt.pointLocation(x(:),y(:));

Error in vec2mtx>cellCentersInPolygon (line 157)
in = inpolyfast(glon, glat, lon, lat);

Error in vec2mtx (line 109)
Z(~cellCentersInPolygon(lat, lon, sizeZ, R1)) = 2;

Error in land_or_ocean (line 65)
[Z, R] = vec2mtx(coast.lat, coast.long, ...
---------------------------------------

Some instances are the (lat,lon) couples (-19,41), (-68,163), (47,-127), (74,-72).
It looks like these locations might be at the same (or very close to same) distance from two different shores.

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: borders