Interpolate MATLAB geoscatter/geoplot data to estimate average wind speeds in the Gulf of Mexico?
18 views (last 30 days)
Show older comments
I'm trying to plot a map of the average wind speeds in the gulf of mexico using a data table (table.txt) collected from a variety of buoys. Column 1 is the latitude coordinates, Column 2 is longitude, and column 3 is wind speed values, which is my color variable. My Plot is shown below:
I want to find a way to "interpolate" or blend the colors together so that the entire (or most) of the ocean is a large color gradient of the average wind speeds. Ideally I would want to keep it in the geoplot format since eventually I will layer bathemetry contours on top. My code is shown below:
figure
geoplot(ais_lat, ais_long, 'o','MarkerSize', 1); %ais data for plotting ship traffic (blue lines)
hold on
tbl = readtable("table.txt");
s = geoscatter(tbl,"latitude","longitude","filled"); %geoscatter function for wind speeds
s.SizeData = 30;
s.ColorVariable = "wind_speed";
c = colorbar;
c.Label.String = "AVG 2022 Wind Speed (knts)";
geolimits([25.07 30.71],[-97.42 -88.04])
title('2022 Collected Average Wind Speed Data: Western GOM');
Can anyone let me know if this is possible? Or do I need to pivot and approach this differently? I appreciate all help!
0 Comments
Answers (2)
Pratyush
on 16 Oct 2023
Hi Lulu,
I understand that you have a geoplot which has plotting of windspeeds at different coordinates and you want to interpolate the colors together to form a gradient of average wind speeds.
The following code snippet demonstrates how you can interpolate wind speeds onto the grid:
figure
geoplot(ais_lat, ais_long, 'o','MarkerSize', 1); % AIS data for plotting ship traffic (blue lines)
hold on
tbl = readtable("table.txt");
lat = tbl.latitude;
lon = tbl.longitude;
wind_speed = tbl.wind_speed;
% Create a grid of latitude and longitude values
lat_grid = linspace(min(lat), max(lat), 100);
lon_grid = linspace(min(lon), max(lon), 100);
[lon_grid, lat_grid] = meshgrid(lon_grid, lat_grid);
% Interpolate wind speeds onto the grid
wind_speed_interp = griddata(lon, lat, wind_speed, lon_grid, lat_grid);
% Plot the interpolated wind speeds as a surface
geoshow(lat_grid, lon_grid, wind_speed_interp, 'DisplayType', 'surface');
c = colorbar;
c.Label.String = "AVG 2022 Wind Speed (knts)";
geolimits([25.07 30.71],[-97.42 -88.04])
title('2022 Collected Average Wind Speed Data: Western GOM');
See Also
Categories
Find more on Geographic Plots 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!