How to change land data to NaN?
Show older comments
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 Comments
Geoff Hayes
on 27 Oct 2014
Eve - what is the nature/format of your coastline and islands files? How is this related to your plotted bathymetry data?
eevee
on 28 Oct 2014
Geoff Hayes
on 29 Oct 2014
Eve - how do you (currently) calculate the volume? What information do you use for that?
eevee
on 30 Oct 2014
Answers (2)
Kelly Kearney
on 27 Oct 2014
3 votes
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 Comments
Chad Greene
on 27 Oct 2014
interpm2 may be used to densify polygons to a given spacing in meters or kilometers.
eevee
on 30 Oct 2014
Kelly Kearney
on 30 Oct 2014
Have you looked at inpolygon, as I suggested?
eevee
on 31 Oct 2014
eevee
on 31 Oct 2014
Kelly Kearney
on 31 Oct 2014
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
on 5 Dec 2014
0 votes
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
