Determine if a point is over land or water

Given a point (latitude, longitude), is there a function or easy way to determine if the point is over land or over water?
I could download coastline data from NOAA and determine if a point falls inside a polygon, but I'd rather not develop an algorithm myself if it already exists.

2 Commenti

I see that File Exchange has a function gebconetcdf that someone created, and then I discovered the code that I need:
gebconc = netcdf.open('gebco_2021_n60.0_s10.0_w-90.0_e-40.0.nc', 'NOWRITE');
XGRID = netcdf.getVar(gebconc,0);
YGRID = netcdf.getVar(gebconc,1);
BATHY = netcdf.getVar(gebconc,2);
netcdf.close(gebconc);
ncread is simple to use.

Accedi per commentare.

 Risposta accettata

KSSV
KSSV il 21 Ago 2021
For a given lon, lat; use interp2 and get the elevation/ bathymetry value, if the value is negative it is depth and lies in the ocean or water and if the value is positive it lies in the land.

5 Commenti

Do you have an algorithm to read the binary *.nc file into an array variable?
Read about the function ncread.
The ncread function wants the variable name and I'm not sure how to extract the 2-byte integer values of elevation from the NetCDF file.
Read about ncdisp. This function will give you variables from there you give the variable name.
Yes, I can see that both ncdisp and ncinfo tell me all about the structure, what I wanted was the few lines of code that allow me to read the binary file into Matlab variables.

Accedi per commentare.

Più risposte (1)

John
John il 9 Set 2024
There is now an API service called IsItWater.com which will let you check with a webservice call:
Request
curl 'https://isitwater-com.p.rapidapi.com/?latitude=41.9029192&longitude=-70.2652276&rapidapi-key=YOUR-X-RAPIDAPI-KEY'
Response
{
"water": true,
"latitude": 41.9029192,
"longitude": -70.2652276
}

Prodotti

Release

R2020b

Richiesto:

il 21 Ago 2021

Risposto:

il 9 Set 2024

Community Treasure Hunt

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

Start Hunting!

Translated by