how to show my output data in map.

sir i want to plot my own output data in map.please help me. how will do this.sir i have 8 years annual time series of rainfall frequency and sir my data size is (20x22x8)(lon,lat,time).
thank you in advance.please sir help me.

 Accepted Answer

Kelly Kearney
Kelly Kearney on 12 Jun 2014
Edited: Kelly Kearney on 12 Jun 2014
I reaally shouldn't be giving you the answer, since you've shown absolutely no effort to create this plot yourself. But I'm bored at work waiting for some simulations to finish, so it's your lucky day.
First of all, I'm assuming that you already have a shapefile holding the India boundary, and that you have a raster grid of x (lon), y (lat), and z coordinates. Also, I'm assuming that your data grid isn't already trimmed to the India borders.
So, the first quick-and-dirty way to do this is to simply mask the data points outside the border:
file = 'TM_WORLD_BORDERS-0.3.shp';
S = shaperead(file, 'usegeocoords', true, 'selector', ...
{@(x) strcmp(x,'India'), 'NAME'});
x = linspace(min(S.Lon), max(S.Lon), 100);
y = linspace(min(S.Lat), max(S.Lat), 100);
[x,y] = meshgrid(x,y);
z = rand(100);
isin = inpolygon(x,y,S.Lon,S.Lat);
z2 = z;
z2(~isin) = NaN;
figure('color','w');
worldmap('India');
pcolorm(y,x,z2);
plotm(S.Lat, S.Lon, 'k');
You'll notice that things get a little jagged around the edges, though. You can get a cleaner map by plotting all the data, then overlaying it with a polygon that masks out all but your region of interest. (Or in this case, polygons, since neither geoshow nor patchm tend to play well with polygons with holes):
lnlim = [65 100];
ltlim = [5 40];
lt = linspace(ltlim(1), ltlim(2), 3);
ln = linspace(lnlim(1), lnlim(2), 3);
for ii = 1:2
ltbox{ii} = lt([1 2 2 1 1]'+(ii-1));
lnbox{ii} = ln([1 1 2 2 1]'+(ii-1));
end
[lnmask, ltmask] = deal(cell(2));
for ii = 1:2
for jj = 1:2
[lnmask{ii,jj}, ltmask{ii,jj}] = polybool('-', ...
lnbox{ii}, ltbox{jj}, S.Lon, S.Lat);
end
end
ltboxall = ltlim([1 2 2 1 1]);
lnboxall = lnlim([1 1 2 2 1]);
[lnmaskall, ltmaskall] = polybool('-', lnboxall, ltboxall, S.Lon, S.Lat);
figure('color','w');
worldmap('India');
pcolorm(y,x,z);
for ii = 1:4
patchm(ltmask{ii}, lnmask{ii}, 'w', 'edgecolor', 'none');
end
plotm(ltmaskall, lnmaskall, 'k');

9 Comments

devendra
devendra on 13 Jun 2014
Edited: devendra on 13 Jun 2014
Thank you so much sir for your support sir.sorry sir but i can not understand about raster grid.i am new in this field so i know only little bit about this. sir my output rainfall frequency data is 3d.i am attaching my shape and my output data.
I am sorry Devendra, but this sounds a lot that you want someone to do the work for you. That is not what this forum is intended for.
Please show what you have done and ask specific questions. People here LIKE to help and teach. The way you are posing your question however sounds a lot like: "Please do this for me", and there are not many here that are willing to just do somebody else's work.
What Kelly has shown you should take you a long way towards solving your problem. But even then, you don't seem too inclined to put some effort yourself. "I can not understand about raster grid". What can't you understand? Have you googled? What particular concept is baffling you?
By raster data I mean the rainfall data. Or rather, one 2D slice of the rainfall data, because obviously you can't plot all the data at once. As for what to do with the third dimension, that's up to you. As Jose-Luis has pointed out, this is an education forum, not a consulting firm. Unless you care to hire and pay me, I've done far too much already.
And please stop calling me sir... I find it a somewhat insulting assumption.
José-Luis sir,sorry sir but you every time posted here negative thing not related to question,this is not good thing. i am really in problem so i am asking here.if you don't like my question then ignore my question.
devendra
devendra on 13 Jun 2014
Edited: devendra on 14 Jun 2014
Kelly Kearney ma'am thank you so much for your support and you are very nice. ma'am now i am stopping my conversation and i will try my self but this is very difficult for me. and sorry for calling you sir.i did not have any idea that you are female.again sorry ma'am
Cedric
Cedric on 13 Jun 2014
Edited: Cedric on 13 Jun 2014
I have to admit that, if it were not an obvious misunderstanding, I'd be tempted to edit out the sir for saving the windows of the NOAA building from exploding ;-)
I am sorry you take it like that, I was just trying to help you learn Matlab. Berating people is not really my idea of fun.
Also, from her comment, one can deduce that Kelly is a woman.
Good luck with your problem.
Kelly Kearney ma'am thank you so much for your support and you are very nice person. ma'am now i am stopping my conversation and i will try this my self but this is very difficult for me. and sorry for calling you sir.i did not have any idea that you are female.again sorry ma'am
Dear Kelly Kearney, How to make multiple sub-plots for the same? I tried but it not able to do. Thank you

Sign in to comment.

More Answers (3)

you could take a look at the demos within Matlab documentation. You will find many working examples on data representation, like this one:
z=peaks(25);
surf(z);
colormap(jet);
Adapt your data to any of those examples.

5 Comments

sir i want to fill data in indain region(map) like attached figure.i am trying all thing but i am unable to do this.please help me sir.
You say your data size is (20x22x8)(lon,lat,time), could you give an example row of any year? I guess you have a 20x22 matrix for each year, but I'm guessing what's the 20x22 data
i am attaching my data but my
lon (X1) =
68.9063
70.3125
71.7188
73.1250
74.5313
75.9375
77.3438
78.7500
80.1563
81.5625
82.9688
84.3750
85.7813
87.1875
88.5938
90.0000
91.4063
92.8125
94.2188
95.6250
and lat (Y1) =
7.7042
9.1050
10.5058
11.9065
13.3073
14.7081
16.1088
17.5096
18.9104
20.3111
21.7119
23.1127
24.5134
25.9142
27.3150
28.7157
30.1165
31.5172
32.9180
34.3188
35.7195
37.1203
There is no way you can get such a high-resolution map with the data you have.
devendra
devendra on 10 Jun 2014
Edited: devendra on 11 Jun 2014
sir there is not necessary that high-resolution map but problem is that how to do this thing.

Sign in to comment.

You will have to present your data by year:
XX YY]= meshgrid(X1,Y1);
z=ltm(:,:,1);
surf(XX,YY,z')
xlabel('XX')
ylabel('YY')
view([0 90])

11 Comments

Thank you so much sir but when i am using this code then showing blank figure.sir how can do this thing from shape file.please sir help me.
I'm guessing the density of your data is too high, hence the outlines of the grid cells are overwhelming the colors. Try adding
shading flat
after whatever you did to plot.
As for reading from a shapefile, do you have the Mapping Toolbox? (Several people asked this when you posted your original question, and you have yet to answer). If so, look at shaperead.
sir,i have map viewer
sir,i have map viewer
What is "map viewer"? Does your license include the Mapping Toolbox? If you type ver, do you see it listed?
Did shading flat help at all?
You're going to have to put some effort in here, or we can't help you.
You keep asking for help, but you are not really answering the requests for clarification properly. That makes it difficult for people to help you.
devendra
devendra on 12 Jun 2014
Edited: devendra on 12 Jun 2014
sorry sir,i don't know about this.how does check tool box? when i wrote ver then got that i have mapping toolbox.but sir i want to plot this from shapefile.you have any idea about this,how will do this from shapefile?
Have you tried reading the documentation
doc shaperead
doc plotm
yes sir i have already read but i am unable to do this
José-Luis
José-Luis on 12 Jun 2014
Edited: José-Luis on 12 Jun 2014
So please post some code showing what you have tried so far.
geoshow('map.shp', 'FaceColor', [0.9 0.9 0.9])
this code is polting india map but i have no idea about next step. i also read about contourfm function but how will use this for my output data i have no idea.

Sign in to comment.

As I have a question on the above example I will utilize this thread, hope that is alright. I am using the presented code to mask the data points outside the border. Works fine so far. However, I want to use the DisplayType surface. Thus I am using geoshow to plot the data. Unfortunately it does not fill the whole map within the borders as a buffer is left. Any hint?
file = 'TM_WORLD_BORDERS-0.3.shp';
S = shaperead(file, 'usegeocoords', true, 'selector', ...
{@(x) strcmp(x,'India'), 'NAME'});
x = linspace(min(S.Lon), max(S.Lon), 100);
y = linspace(min(S.Lat), max(S.Lat), 100);
[x,y] = meshgrid(x,y);
z = rand(100);
isin = inpolygon(x,y,S.Lon,S.Lat);
z2 = z;
z2(~isin) = NaN;
lnlim = [65 100];
ltlim = [5 40];
lt = linspace(ltlim(1), ltlim(2), 3);
ln = linspace(lnlim(1), lnlim(2), 3);
for ii = 1:2
ltbox{ii} = lt([1 2 2 1 1]'+(ii-1));
lnbox{ii} = ln([1 1 2 2 1]'+(ii-1));
end
[lnmask, ltmask] = deal(cell(2));
for ii = 1:2
for jj = 1:2
[lnmask{ii,jj}, ltmask{ii,jj}] = polybool('-', ...
lnbox{ii}, ltbox{jj}, S.Lon, S.Lat);
end
end
ltboxall = ltlim([1 2 2 1 1]);
lnboxall = lnlim([1 1 2 2 1]);
[lnmaskall, ltmaskall] = polybool('-', lnboxall, ltboxall, S.Lon, S.Lat);
figure('color','w');
worldmap('India');
geoshow(y, x, z2, 'DisplayType','surface')
contourcmap('jet',min(z):1:max(z),'colorbar','on','location','horizontal')
for ii = 1:4
patchm(ltmask{ii}, lnmask{ii}, 'w', 'edgecolor', 'none');
end
plotm(ltmaskall, lnmaskall, 'k');

Products

Community Treasure Hunt

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

Start Hunting!