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

24 次查看(过去 30 天)
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

回答(5 个)

Amy Haskins
Amy Haskins 2015-4-1
编辑:Amy Haskins 2015-4-1
You could also try the inpolygon function.
% Load the coastline
coast = load('coast.mat');
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);

Brett Shoelson
Brett Shoelson 2011-2-9
I think this will do it. It is a binary classifier: Ocean/Land.
coast = load('coast.mat');
[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

John
John 2011-2-9
Perhaps something like this could help:

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

Joshua Carmichael
Joshua Carmichael 2023-10-4
The Matlatb function isinterior.m (new since 2022a) does this.

类别

Help CenterFile Exchange 中查找有关 Mapping Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by