필터 지우기
필터 지우기

Plotting Station Data using pcolor

조회 수: 1 (최근 30일)
Jason
Jason 2011년 4월 11일
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"?

답변 (1개)

Patrick Kalita
Patrick Kalita 2011년 4월 11일
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);

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by