How to change land data to NaN?

Hi,
I have plotted a bathymetry and now I'm given coastline and some islands files where I need to use them to define where the land is and then turn the land data to NaN.
How should I do that?
Thanks, Eve

4 comentarios

Geoff Hayes
Geoff Hayes el 27 de Oct. de 2014
Eve - what is the nature/format of your coastline and islands files? How is this related to your plotted bathymetry data?
eevee
eevee el 28 de Oct. de 2014
Hi Geoff,
I have included my land data in the volume calculation and now my lecturer gave me the xyz files of the land data (i.e. both coastline and islands file). I was asked to use the all those files into my matlab script to tell matlab not to included the land data into the calculation. So, now I do not know how to tell matlab about that. Any ideas?
Thanks,
Eve
Geoff Hayes
Geoff Hayes el 29 de Oct. de 2014
Eve - how do you (currently) calculate the volume? What information do you use for that?
eevee
eevee el 30 de Oct. de 2014
Hi Geoff,
I use:
dx*dy*zi(~isnan(zi))
However, my zi includes both land and sea data. So now, I need to remove the land data before I could calculate the volume of bathymetry. I don't know how to tell matlab that my land data are those that falls below the coastline (please see image below)
Thanks,
Eve

Iniciar sesión para comentar.

Respuestas (2)

Kelly Kearney
Kelly Kearney el 27 de Oct. de 2014

3 votos

The inpolygon function will do most of the work. Depending on the scale of your region and the format of the coastlines, you may need to close off polygons, reverse order of vertices, and upsample polygons in order to get the best results; the Mapping Toolbox has several functions ( flatearthpoly, interpm, ispolycw, poly2cw) to help with that.

6 comentarios

Chad Greene
Chad Greene el 27 de Oct. de 2014
interpm2 may be used to densify polygons to a given spacing in meters or kilometers.
eevee
eevee el 30 de Oct. de 2014
Hi Chad,
The above image is the bathymetry plot that I've obtained. I was asked to remove the land data (i.e. the data that falls below the coastline) before calculating the volume of my bathymetry.
Any idea how should I do it? I've tried using ginput to select points of an irregular area but I do not know how to proceed from those points selected and making it into an area that I can subtract it from.
Thanks, Eve
Kelly Kearney
Kelly Kearney el 30 de Oct. de 2014
Have you looked at inpolygon, as I suggested?
eevee
eevee el 31 de Oct. de 2014
Hi Kelly,
I have looked into that, but I'm still unsure how should I put it into my script. Could you please advise me?
Please find attached my script.
p/s: i find my volume by vol=dx*dy*sum(zi_diff(~isnan(zi_diff) & zi_diff>=1)); %line 84
However, my lecturer do not want me to use *zi_diff>=1* to define the land data. He wants me to find the indices of xi,yi,and zi_diff that falls under the coordinates of coastline. After that, I sub the indices back into the matrix of xi,yi,zi_diff to get the value before I could calculate the volume of the bathymetry. I'm guessing I need to do a loop for that, but I've been trying and still fail.
Hope to hear from you soon! Really need to get this done!
Thanks, Eve
eevee
eevee el 31 de Oct. de 2014
Hi Kelly,
sorry I just realized I forgot to attach my script. :)
Can you upload the coastline file? The answer will depend on whether it contains just the visible line segments you plotted above, or fully-closed polygons. Assuming it's the latter, your code to mask the land points will look something like:
isin = inpolygon(xi, yi, xcoast, ycoast);
zi_diff(isin) = NaN;
But you may need to do some processing of xcoast and ycoast to convert them to closed, clockwise polygons.

Iniciar sesión para comentar.

Chad Greene
Chad Greene el 5 de Dic. de 2014

0 votos

Another solution is the landmask function on File Exchange.

Categorías

Preguntada:

el 27 de Oct. de 2014

Respondida:

el 5 de Dic. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by