필터 지우기
필터 지우기

how to show my output data in map.

조회 수: 3 (최근 30일)
devendra
devendra 2014년 6월 10일
댓글: Srishti Gaur 2018년 5월 3일
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.

채택된 답변

Kelly Kearney
Kelly Kearney 2014년 6월 12일
편집: Kelly Kearney 2014년 6월 12일
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
devendra
devendra 2014년 6월 14일
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
Srishti Gaur
Srishti Gaur 2018년 5월 3일
Dear Kelly Kearney, How to make multiple sub-plots for the same? I tried but it not able to do. Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

David Sanchez
David Sanchez 2014년 6월 10일
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
José-Luis
José-Luis 2014년 6월 10일
There is no way you can get such a high-resolution map with the data you have.
devendra
devendra 2014년 6월 10일
편집: devendra 2014년 6월 11일
sir there is not necessary that high-resolution map but problem is that how to do this thing.

댓글을 달려면 로그인하십시오.


David Sanchez
David Sanchez 2014년 6월 11일
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
José-Luis
José-Luis 2014년 6월 12일
편집: José-Luis 2014년 6월 12일
So please post some code showing what you have tried so far.
devendra
devendra 2014년 6월 12일
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.

댓글을 달려면 로그인하십시오.


peterhack
peterhack 2016년 11월 11일
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');

Community Treasure Hunt

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

Start Hunting!

Translated by