Mapping Toolbox - Equivalent to imagesc instead of surfm?

6 views (last 30 days)
I have a dataset (drho.txt) which contains three vectors: longitude, latitude and drho. Each drho datapoint represents a block of 0.5x0.5 degrees, centered at the corresponding lon/lat. Until recently I've used imagesc (before that surf) to plot this, but the Mapping Toolbox seems to fit my needs better. The nature of my data is such that the outer layer is quite different from the inner area (e.g. -250 on the edge vs 250 in the middle), like a border that is one datapoint in thickness. So if I use colormap jet, with imagesc I'll get a nice blue rim around my orange and red data. With surf, however, only two edges turn blue and the other two are red like the inside, presumably due to the color being defined by the height. As I wanted to show the entire blue border, I switched to imagesc. Now that I'm using the Mapping Toolbox, I'd like to get the similar results, but with the proper geometric visualization, especially at higher latitudes.
tl;dr: I'm looking for the equivalent to imagesc in the Mapping Toolbox, instead of surfm.
%define lon/lat range
lon_drho = 259.25:0.5:272.75;
lat_drho = -25.75:0.5:-12.25;
%load data: [lon lat drho]
drho_data = load('drho.txt');
%reshape drho data to matrix
drho_matrix = reshape(drho_data(:,3),length(lon_drho),length(lat_drho));
%First
f1 = figure(1);
h1 = surf(lon_drho,lat_drho,drho_matrix');
view([0 90])
caxis([-250 250])
colormap jet
%Then
f2 = figure(2);
h2 = imagesc(lon_drho,lat_drho,drho_matrix');
view([0 -90])
caxis([-250 250])
colormap jet
%Now
%eqdconic
f3 = figure(3);
h3 = worldmap([lat_drho(1) lat_drho(end)],[lon_drho(1) lon_drho(end)]);
s3 = surfm(lat_drho,lon_drho,drho_matrix');
caxis([-250 250])
colormap jet
%Want
%eqdconic
f4 = figure(4);
h4 = worldmap([lat_drho(1) lat_drho(end)],[lon_drho(1) lon_drho(end)]);
s4 = imagesc(lat_drho,lon_drho,drho_matrix');
caxis([-250 250])
colormap jet

Answers (1)

Chad Greene
Chad Greene on 13 Jan 2017
Take a look at geoshow. You'll need to make a grid first, but I think you can get the results you're seeking with the 'texturemap' option. Try this:
[lon,lat] = meshgrid(lon_drho,lat_drho); % <- MAKE A GRID.
f4 = figure(4);
h4 = worldmap([lat_drho(1) lat_drho(end)],[lon_drho(1) lon_drho(end)]);
s4 = geoshow(lat,lon,drho_matrix','displaytype','texturemap'); % <-USE GEOSHOW
caxis([-250 250])
I also suggest not using colormap jet to represent data. Jet's lightness profile introduces false gradients and has a tendency to put emphasis on arbitrary values in your dataset. Consider using a colormap with a linear, or at least monotonic lightness profile. If this is dataset represents anomalies, or some change relative to the zero value, use a diverging colormap such as cmocean's balance or curl colormaps. Here's what it would look like for your dataset:
cb = colorbar('southoutside');
xlabel(cb,' some anomaly value ')
cmocean balance
  2 Comments
Eduard
Eduard on 14 Jan 2017
Hi Chad,
Thanks for your reply! Thanks for pointing me towards cmocean, using cmocean balance does look much better.
Two days ago someone emailed me in response to this question, who suggested that I extend the drho_matrix with dummy values, and shifting of lon/lat values, as the bottom left part gets plotted with surfm. What I then get is the following figure. The meridians and parallels are then perfectly lined up with the blocks, which is exactly what I want. In your figure, you can see that e.g. the parallel at 25 degrees South goes straight through the blocks, instead of running between them.
Thanks again for your help,
Eduard
Chad Greene
Chad Greene on 16 Jan 2017
Ah, yes, that's a question of whether the postings align with the center of each pixel or a corner of each pixel--a good thing to check anytime you have gridded data. Glad you got it working!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!