Determining whether a point on earth (given latitude and longitude) is on land or ocean
조회 수: 19 (최근 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
댓글 수: 1
Walter Roberson
2011년 2월 9일
Where do you place the dividing line for estuaries ? Or for reclaimed land?
답변 (6개)
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);
댓글 수: 0
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
댓글 수: 1
Dan Chavas
2014년 2월 11일
I've put this code into a MATLAB file: http://www.mathworks.com/matlabcentral/fileexchange/45268-landorocean-m
Joshua Carmichael
2023년 10월 4일
The Matlatb function isinterior.m (new since 2022a) does this.
댓글 수: 0
Kurt
2025년 2월 4일
편집: Kurt
2025년 2월 4일
There is an even simpler solution, similar to Amy Haskins above, that does not even require the use of geo data.
I'm working with digital data. The satellite scans a patch of the Earth and sends back the lat and lon coordinates of each sample point in a 571 x 318 array.
I wanted to use the isinterior() function to tell if a point is inside or outside the shoreline, but it doesn't work with geopolyshape data. I realized that you don't need to use geo objects for this, just a simple axis object.
gx = axes;
load coastlines;
coast = polyshape(coastlon, coastlat)
plot(gx, coast);

Then as you cycle through each satellite lat/lon array, you call isinterior:
idxLand = isinterior(coast,lon,lat);
landlon = lon(idxLand);
landlat = lat(idxLand);
This will clip all the data outside the continents. It works like a charm, without resorting to geo data.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!