Plotting rainfall data with latitude and longitude coordinates

23 次查看(过去 30 天)
Hello all, I am currently doing research in remote sensing and I am trying to find a correlation between rainfall and flooding. My mentor wants me to use MATLAB and place data on a plot that has the longitude and latitude coordinates for Uttarakhand India. My problem with this is the coordinates pop up but the image does not and I do not understand why.
Here is the code:
latlim = ([28 32]);
lonlim = ([77 82]);
precip_uttar_06_20=precipitation_06_20(72:88,1029:1045);
colorbar('vert','FontSize',12);
title('Precipitation');
ax = worldmap(latlim, lonlim);
img=imagesc(precip_uttar_06_20);
geoshow(ax,img,precip_uttar_06_20);
I am using Tropical Rainfall Measurement Mission Data from NASA and he wants me to create a map that shows the rainfall at a specific day at a specific country but when i run the entire code, it says geoshow has an error
Please help, anything would be greatly appreciated I have been stuck for the past week on this code.
And yes I have m_map installed and i use MATLAB 2008
Thanks

回答(1 个)

Kelly Kearney
Kelly Kearney 2014-7-23
编辑:Kelly Kearney 2014-7-23
The geoshow function will plot your data... no need to create an image as an in-between. As you called it, you passed 2D data, with the img values as your latitudes and precip_uttar_06_20 as the longitude. Since img is in reality a single handle value (as returned by imagesc) with a value less than one, you've plotted a few points along the equator, well outside your map range (and depending on your precipitation values, possibly well off the surface of the Earth).
To plot this properly, you need the longitude and latitude values corresponding to the data in precip_uttar_06_20. I've assumed below that points are evenly spaced between your specified lat and lon limits.
Correct syntax:
latlim = ([28 32]);
lonlim = ([77 82]);
precip = rand(15, 20); % Put your data here...
[nr, nc] = size(precip);
lat = linspace(latlim(1), latlim(2), nc); % ... and your real lat and lon here
lon = linspace(lonlim(1), lonlim(2), nr);
[lat, lon] = meshgrid(lat, lon);
ax = worldmap(latlim, lonlim);
geoshow(lat, lon, precip, 'displaytype', 'texturemap');
colorbar('vert','FontSize',12);
title('Precipitation');
Also, worldmap and geoshow are part of Matlab's Mapping Toolbox, while m_map is an external non-Mathworks toolbox for maps. Both have their advantages and disadvantages, but in this case you don't need the latter.
  3 个评论
Kelly Kearney
Kelly Kearney 2014-7-24
The rand call was just to generate some random data, since I didn't have access to your precipitation array. You should still generate precip as you did before:
precip = precipitation_06_20(72:88,1029:1045);
I assume you must have lat/lon coordinates to go along with the precipitation_06_20 array? If so, I would recommend just plotting the full array, rather than trying to subset it... nothing beyond the map boundaries will show up anyway.
Nurul Ain Basirah Zakaria
Hi. I want to plot and visualize 3-dimensional precipitation data.
CHIRPS=1x140X170
I tried to use same way as yours but nothing is working perfectly.
>> geoshow(lat, lon, chirpsms, 'displaytype', 'texturemap');
Error using surface
Value must be a 2D or 3D array of numeric type.
Error in internal.mapgraph.SurfaceAdapter/displaySurface (line 173)
h.SurfaceHandle = surface(surfaceProps);
Error in internal.mapgraph.SurfaceAdapter/refresh (line 84)
h.displaySurface(surfaceProps);
Error in internal.mapgraph.GeoRaster/refresh (line 243)
refresh@internal.mapgraph.SurfaceAdapter(h, varargin{:});
Error in internal.mapgraph.SurfaceAdapter (line 52)
h.refresh(S);
Error in internal.mapgraph.GeoRaster (line 208)
h = h@internal.mapgraph.SurfaceAdapter(ax, ...
Error in georastershow>geosurface (line 200)
g = internal.mapgraph.GeoRaster(ax, Z, SpatialRef, ...
Error in georastershow>displayGeoRasterData (line 167)
h = geosurface(ax, Z, SpatialRef, displayType, HGpairs);
Error in georastershow (line 147)
h0 = displayGeoRasterData(ax, displayType, Z, SpatialRef, HGpairs);
Error in geoshow (line 242)
h = showFcn(varargin{:});

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by