Applying a mask creates an odd artifact in the resulting map
14 views (last 30 days)
Show older comments
I am trying to limit a map to the data included within Denmark's EEZ. For example:

The EEZ shape file was downloaded from here: https://www.marineregions.org/gazetteer.php?p=details&id=5674
I want to include everything that is within the black lines. To do this, I am reading in the original mapping data, which is stored in a nc file, with 4D data (lat, lon, frequency, percentile). I extract it as so:
sample23 = 'path to nc file'
energy23 = ncread(sample23, '/AcousticData/energy');
lat = ncread(sample23, '/AcousticData/lat');
lon = ncread(sample23, '/AcousticData/lon');
prtc = ncread(sample23, '/AcousticData/percentile');
frq = ncread(sample23, '/AcousticData/frequency');
[num_lat, num_lon, num_percentile, num_freq, ~] = size(energy23);
% Create mask
eez=shaperead('./ShapeFiles/eez/eez.shp'); % From link above
[LonGrid, LatGrid] = meshgrid(lon, lat); % Note: lat is Y, lon is X
Y=eez.Y(~isnan(eez.Y))';
X=eez.X(~isnan(eez.X))';
inPoly = inpolygon(LonGrid, LatGrid,X,Y);
%apply EEZ mask
energy23sub=reshape(energy23, [],num_percentile*num_freq);
energy23sub(~inPoly, :)=nan;
energy23sub=reshape(energy23sub, size(energy23));
This has worked on other areas. However, when I apply this mask to these data, this is the resulting map that I get:

Where part of the data has been displaced/flipped to outside of the EEZ polygon. Can anyone help explain this? Or have any ideas on how to fix it?
I am sorry that I can not supply the data within the nc file.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!