How to prevent wraparound using geoplot
Show older comments
I am trying to accomplish something similar to the below post, namely prevent my data from wrapping at the meridians. So far, no luck:
If I set the lonLim to [-360 360] and call geolimits(latlim,lonlim), the longitude limits do NOT change to [-360 360] but to [-180.3914 181.1743]. Why is this? Is there a bult-in max limit in geolimits? It's possible that the function is confused by the [-360 360] values, which are effectively equivalent.
But back to the wraparound issue. I am plotting NetCDF-type satellite observation data.
figure
gx = geoaxes;
geobasemap(gx,'usgsimagery');
hold on
latLim = [-72 85];
lonLim = [-180 180];
geolimits(gx, latLim, lonLim);
lat = ncread(filepath, 'Latitude'); % read NetCDF-type data
lon = ncread(filepath, 'Longitude');
lat1 = double(lat(:,:,1)) ; % read just the 1st of 6 layers
lon1 = double(lon(:,:,1));
lon1 = wrapTo180(lon1); % limit to +/- 180 degrees
k = boundary(lat1(:),lon1(:)); % get just the edge data
pgon = geopolyshape(lat1(k),lon1(k));
geoplot(gx,pgon);
I am able to plot the satellite observation patches on the Mercator projection geoaxes display. However, when a patch crosses the International Date Line, it does not straddle the line but whangs all the way to the right, to the Prime Meridian.
If I use geoplot instead of geopolyshape I get the same effect, only with vectors instead of shapes.When the longitude data reaches -180, the vectors jump all the way to the right instead of straddling the dateline.
geoplot(gx,lat1(k),lon1(k));
How can I massage my NetCDF data to prevent this?
My goal is to collect all the patches and merge them into a single surface as described here:
5 Comments
Kurt
on 3 Jan 2025
Deg = [-147.75 -152.944 -158.91 -165.725 -173.292 178.5214 170.0151 161.5731 153.4542 146.0499 ]
rad2deg(unwrap(deg2rad(Deg)))
Deg = [-147.75 -152.944 -158.91 -165.725 -173.292 178.5214 170.0151 161.5731 153.4542 146.0499 ]
Deg(Deg<0) = 360 + Deg(Deg<0)
Kurt
on 6 Jan 2025
Kurt
on 8 Jan 2025
Answers (1)
Categories
Find more on Mapping Toolbox 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!