Azzera filtri
Azzera filtri

Interpolate MATLAB geoscatter/geoplot data to estimate average wind speeds in the Gulf of Mexico?

11 visualizzazioni (ultimi 30 giorni)
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!

Risposte (2)

Pratyush
Pratyush il 16 Ott 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');
  1 Commento
Lulu
Lulu il 16 Ott 2023
Hi Pratyush,
Thank you for your response! When running your example code I am met with the subsequent error:
Error using scatteredInterpolant
The coordinates of the input points must be finite values; Inf and NaN are not permitted.
I started to play around with the grid data function with help from This Question, since that is what seems to be causing the error, but I cannot find a way to resolve it. Is there an error in my data set causing a lat/lon value to be 0? Or is it my matrix? Once again I appreciate all help!

Accedi per commentare.


KSSV
KSSV il 16 Ott 2023

Categorie

Scopri di più su Geographic Plots in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by