Hello, I have an issue I've been working on for days. I am using ocean bathymetries, and I've created contours of depth. I have used:
[C,h] = contourfm(lat,lon,depth)
This works, and looks great, and I understand the structure of C.
The next task is to see if a series of points which have depth data are inside or above these contours, the implication being that these points are within the ocean, and not below the bottom of the ocean. I have used a series of loops, but basically:
patchstart = find(C(1,:)==pointdepth);
IN = inpolygon(pointx,pointy,xv,yv);
There may be some errors above, as I've simplified it.
Basically, this works just fine. The problem is that the shapes in C aren't necessarilly 'closed'. The contours (bathymetry lines) are sometimes drawn in curvy fashion from one side of the plot to the other. Thus, when INPOLYGON checks the polygon, it CLOSES that polygon in a straight line from where the shape hits each edge of the axis. Because these lines are curvy and complex, the result is a crazy polygon that is not even close to accurate (that straight line suggests that some areas that are OUTSIDE of the contour are in, and some areas that are INSIDE end up being out - think of drawing a sin-wave, then drawing a line down the middle, and shading just the 'closed' areas).
So the issue is this: Is there a way to close a polygon by wrapping around the current set of axes? I'm not even sure that would solve my problem in all cases, but it might get me closer.
The CONTOURFM function draws the contours PERFECTLY, but the shapes in C are INCORRECT when redrawn with PATCH, etc.
Thanks for the help! (first time post!)
No products are associated with this question.