how to make a geographic map from text files data
7 次查看(过去 30 天)
显示 更早的评论
Hi every one;
I have data in text file which has three columns , first column is latitude , second is long and third column is related to air temperature. Header is removed from the file so that it only contains the values in text file.
I have such data for every month. Like in April folder i have make three text files
- 1-1000 % this text file contains values of temperature at given lat, long with in 1-1000m height
- 1000-2000 % This text file contains temperature values at given lat, long with 1000-2000m height
- 2000-3000 % ....................................................................2000-3000m.......
- above 3000 % ...................................................................above 3000m......
I want to make a code which read this text files makes the title "0-1000 Temperature variations" , also lable x,y axises as latitude or longitude. This map shows variations in temperature with height. Color variations in maps shows by scale.
For the shake , i have mentioned below some output of my map which i want. I am also sharing with you people text file of 1-1000m. I have no idea how to make such map in matlab or any other.Please help me i shall be very thankful to you on this kind favor.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152106/image.png)
0 个评论
采纳的回答
bio lim
2015-7-13
Hi, Muhammad. This is not an exact solution to your problem, but this is how you can do it. Firstly, I would create a structures that contains your data given in your text files.
For example, using your file ' 1-1000.txt ',
fid = fopen('1-1000.txt');
C = textscan(fid, '%f %f %f')
fclose(fid);
f = {'lat', 'long', 'temp'}
S = cell2struct(C,f,2);
Now I have a structure S that has three fields, .lat, .long and .temp.
Now we need two things. The first one is you need the map that is given in the back of your plots. Assuming that you have it, you can just load the map by
load(map.mat)
Then we need to change your decimal degrees (long and lat) to meters. There are many methods available, even mercator.m files available on the File Exchange. Generally, it should look something like this.
radian = degree * pi/180; % Since your S.long and S.lat are given in decimal degrees.
earth_radius = 6378.137;
lng = (x * radian - 135/180*pi) * earth_radius; %[km]
lat = atanh(sin(y)) * earth_radius; %[km]
Since you have a structures, it is better to write function mercator that your data can easily be implemented.
Finally, for the color variated map, you can use imagesc.
N = 1000;
[Xi, Yi] = meshgrid(linspace(37,42,N),linspace(-6.9,2.5,N));
Ci = griddata(A(:,2), A(:,1), A(:,3), Xi, Yi);
colormap ('hot')
imagesc(linspace(37,42,N),linspace(-6.9,2.5,N),Ci);
xlabel('Longitude');
ylabel('Latitude');
colorbar
Now, this will not instantly work. It will take quiet some time for you to search each function and implement it appropriately to your own data. The codes provided above might be confusing, but I wrote them merely to show you how they could be implemented.
19 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!