Determining whether a point on earth (given latitude and longitude) is on land or ocean

83 views (last 30 days)
Soumyadeep Chatterjee on 9 Feb 2011
Edited: Amy Haskins on 1 Apr 2015
I am looking for a quick way to determine whether a point on earth's surface (given latitude and longitude) falls on one of the continents or on an ocean.
Any help is greatly appreciated.
Thanks, Deep

1 Comment

Walter Roberson on 9 Feb 2011
Where do you place the dividing line for estuaries ? Or for reclaimed land?

Brett Shoelson on 9 Feb 2011
I think this will do it. It is a binary classifier: Ocean/Land.
[Z, R] = vec2mtx(coast.lat, coast.long, ...
1, [-90 90], [-90 270], 'filled');
figure; worldmap(Z, R)
geoshow(Z, R, 'DisplayType', 'texturemap')
colormap([0 1 0;0 0 0;0 1 0;0 0 1])
lat = 38.53;%N
lon = -57.07;%W
plotm(lat,lon,'ro')
val = ltln2val(Z, R, lat, lon);
isOcean = val == 2
%isLand = ~isOcean
Cheers,
Brett

1 Comment

Amy Haskins on 1 Apr 2015
Edited: Amy Haskins on 1 Apr 2015
You could also try the inpolygon function.
ax = worldmap('world');
geoshow(coast)
% Grab a point from the map
[lat,lon] = inputm(1,ax);
% Determine if it's within the coast polygon
isInland = inpolygon(lat,lon,coast.lat,coast.long);

John on 9 Feb 2011
Perhaps something like this could help:

Chad Greene on 28 Jan 2015
landmask(lat,lon) returns 1 for land, 0 for ocean.