Effacer les filtres
Effacer les filtres

Plotting Station Data using pcolor

1 vue (au cours des 30 derniers jours)
Jason
Jason le 11 Avr 2011
I have over 6000 stations with precipitation data (some with "junk", others with realistic values). I have loaded the data and have computed the trends in the precipitation dataset. I have three vectors:
  1. ptrend - Contains the trends in precipitation for select stations (2428 x 1).
  2. lon - Contains the longitude values for the stations (2428 x 1).
  3. lat - Contains the latitude values for the stations (2428 x 1).
Note: Lat and lon are not evenly spaced.
I am trying to find a way to plot these values on a map. From what I understand, pcolor requires that the input data be a matrix and not a vector. So, I tried repmat:
ptrend_rep = repmat(p_trend,[1 length(p_trend)]);
figure(1);
pcolor(lon,lat,ptrend_rep);
However, the figure comes out looking very strange (striations and "garbage"). I also tried meshgrid for the lat and lon vectors.
[lat2,lon2] = meshgrid(lat,lon);
figure(2)
pcolor(lon2,lat2,ptrend_rep);
Still, the figure looks terrible.
Any ideas how to get this plotted correctly and "nicely"?

Réponses (1)

Patrick Kalita
Patrick Kalita le 11 Avr 2011
You're on the right track that you need to convert your scattered data into gridded data. A good tool for that job is the TriScatteredInterp class.
% Some data
lat = rand(300, 1);
lon = rand(300, 1);
ptrend = peaks(lat, lon);
% Make a TriScatteredInterp object
F = TriScatteredInterp(lat,lon,ptrend);
% Make a grid of lats and lons, based on the min and max of the original vectors
[lat_grid, lon_grid] = meshgrid(linspace(min(lat), max(lat), 50), linspace(min(lon), max(lon), 50));
% Do the interpolation
ptrend_grid = F(lat_grid, lon_grid);
% Now PCOLOR will accept the gridded data
pcolor(lat_grid, lon_grid, ptrend_grid);

Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by