フィルターのクリア

How to change land data to NaN?

4 ビュー (過去 30 日間)
eevee
eevee 2014 年 10 月 27 日
回答済み: Chad Greene 2014 年 12 月 5 日
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 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 10 月 29 日
Eve - how do you (currently) calculate the volume? What information do you use for that?
eevee
eevee 2014 年 10 月 30 日
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

サインインしてコメントする。

回答 (2 件)

Kelly Kearney
Kelly Kearney 2014 年 10 月 27 日
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 件のコメント
eevee
eevee 2014 年 10 月 31 日
Hi Kelly,
sorry I just realized I forgot to attach my script. :)
Kelly Kearney
Kelly Kearney 2014 年 10 月 31 日
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.

サインインしてコメントする。


Chad Greene
Chad Greene 2014 年 12 月 5 日
Another solution is the landmask function on File Exchange.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by