0

I'm making my own Shakemap (so far, Shamemap) with Matlab. A Shakemap is a representation of the intensity of ground shaking in a map (google it up for more info). I want it to be similar to those from the USGS, in which they plot the intensity using a jet colormap and they control the shading to represent the altimetry data. So far I haven't figured out how they do this.

I have a set of coordinates with the location's elevation (from NASA's SRTM) and in the same set of coordinates I have some parameters of ground shaking.

[lat long SRTM]

[lat long GroundShaking]

I can contour them separately, but if I put them in the same figure just like that one overrides the other.

How can I put them in the same figure? I have thought about assigning a new value to each location such that the new value accounts for both measures; locations with the same GroundShaking parameter should be the same color, but if one is higher then that one should be darker. Unfortunately I don't know how to implement this. I have also thought about setting the alpha feature manualy, but I can't make it work only for the Ground Shaking data. Any suggestions ?

MWE:

x=0:0.01:1;
y=0:0.01:1;
[xx,yy]=meshgrid(x,y);
asd1=zeros(length(x),length(y));
ads2=asd1;
for i=1:length(x)
    for j=1:length(y)
        asd1(i,j)=x(i)*y(j);
        asd2(i,j)=x(i)*x(i)+y(j)*y(j);
    end
end
c1=griddata(x,y,asd1,xx,yy, 'linear');
c2=griddata(x,y,asd2,xx,yy, 'linear');
contourf(asd1)
contourf(asd2)
alpha(0.5)

(MWE unrelated to the map because the data is huge)

Ariaramnes
  • 943
  • 2
  • 10
  • 18
  • [How to assign different colormaps/colorbars to different surfaces in the same Figure](http://stackoverflow.com/questions/8073113/matlab-how-to-assign-different-colormaps-colorbars-to-different-surfaces-in-the) might help you. – NoDataDumpNoContribution Jun 02 '14 at 18:02

1 Answers1

0

You need to add a hold on so that the first plot is not overwritten. This nearly works.

colormap gray
map1=colormap
colormap jet
map2=colormap

M=[map1;map2];
asd2=asd2*(max(asd1(:))-min(asd1(:)))/(max(asd2(:))-min(asd2(:)));
asd2=asd2-max(asd2(:));

colormap(M)
caxis([min(asd2(:)) max(asd1(:))])
figure(1)
contourf(asd1)
figure(2)
contourf(asd2)
David
  • 8,449
  • 1
  • 22
  • 32
  • I'm not sure if this is quite what you want, it makes your example code work as it looks like it is meant to though. – David Jun 01 '14 at 22:21
  • Your code works, but it's not what I want exactly. How can I set de colormap to grey in the first and to jet in the second contour?. BTW, thanks! Consider that caxis = [0 5000] in the first contour and [0 1] in the second. – Ariaramnes Jun 01 '14 at 22:25
  • Edited my answer. It's better, but not there yet. I can't fix it now though, sorry. – David Jun 01 '14 at 22:49