0

I want to make color map from text file which contains three columns( 1st is latitude, 2nd is longitude, 3rd is temperature). I have accessed to this code which reading and creating color map from text file (1-1000.text)

fid = fopen('1-1000.txt');
 C = textscan(fid, '%f %f %f')
 fclose(fid);
 f = {'lat', 'long', 'temp'}
 S = cell2struct(C,f,2);

 N = 1000;
 [Xi, Yi] = meshgrid(linspace(60,80,N),linspace(20,40,N));
 Ci = griddata(S.long, S.lat, S.temp, Xi, Yi);
 colormap ('hot')
 imagesc(linspace(60,80,N),linspace(20,40,N),Ci);
 xlabel('Longitude');
 ylabel('Latitude');
 colorbar

I have shapefile of Pakistan(my data is of pakistan) and i want to show this color map variation over the pakistan. But have no idea how to set the background of the color map. For the shake i have attached with this post output of the maps which i required. Please help to resolve my question and thanks in advance for this kind assistance M.Usman Saleem

This the data

Lat      long    temp
27.5    62.5    0
27.5    63.5    0
27.5    64.5    0
28.5    60.5    0
28.5    61.5    0
28.5    62.5    0
28.5    63.5    0
28.5    64.5    0
28.5    65.5    0
29.5    60.5    0
29.5    62.5    0
29.5    63.5    0
29.5    64.5    0
29.5    65.5    0
29.5    68.5    0
29.5    69.5    0
30.5    60.5    0
30.5    62.5    0
30.5    63.5    0
30.5    64.5    0
30.5    65.5    0
30.5    66.5    0
31.5    60.5    0
31.5    63.5    0
31.5    64.5    0
33.5    60.5    0
35.5    74.5    0
35.5    75.5    0
36.5    71.5    0
37.5    72.5    0
37.5    75.5    0
37.5    77.5    0
37.5    78.5    0
38.5    76.5    0
25.5    77.5    228.5
27.5    66.5    106.8
23.5    76.5    192.7
24.5    77.5    188.3
27.5    71.5    26
35.5    61.5    262.4
32.5    60.5    83.6
37.5    60.5    10.7
36.5    61.5    9
36.5    66.5    45.8
36.5    68.5    43.9
24.5    60.5    178.3
23.5    64.5    187.8
31.5    62.5    47.1
26.5    63.5    250.9
22.5    64.5    209.4
23.5    61.5    181.9
23.5    65.5    185
23.5    62.5    172.5
22.5    62.5    179.9
22.5    63.5    184.2
24.5    62.5    173.3
24.5    63.5    178
23.5    63.5    180.4
22.5    65.5    192.8
24.5    64.5    177.2
24.5    65.5    162.7
22.5    61.5    175.9
22.5    66.5    207.61
24.5    61.5    183.6
23.5    66.5    163.2
23.5    60.5    180.4
23.5    67.5    200.4
22.5    67.5    194.6
22.5    60.5    166.2
24.5    66.5    182
25.5    60.5    179.8
23.5    68.5    205.8
22.5    68.5    198.1
37.5    69.5    417
25.5    66.5    43.9
31.5    61.5    159.7
24.5    68.5    11.9
38.5    62.5    74.6
38.5    60.5    63.5
38.5    61.5    114
37.5    61.5    113.4
38.5    64.5    110.7
38.5    63.5    92.8
37.5    63.5    136.1
37.5    64.5    118
37.5    62.5    98.6
38.5    65.5    77.8
37.5    65.5    93.5
37.5    67.5    74.1
37.5    68.5    87.9
36.5    65.5    168.8
37.5    66.5    168.1
36.5    67.5    174.5
38.5    66.5    229.8
25.5    75.5    21.5
28.5    74.5    267.6
28.5    72.5    287.5
28.5    73.5    278
35.5    63.5    281.8
30.5    71.5    2.1
28.5    71.5    307.4
29.5    73.5    237.6
34.5    62.5    202.9
31.5    71.5    202
32.5    71.5    139.6
31.5    73.5    117.6
28.5    68.5    238.9
30.5    72.5    167.3
31.5    72.5    133.1
29.5    72.5    220.8
32.5    73.5    103.7
33.5    72.5    68
28.5    75.5    389.1
35.5    60.5    201.6
29.5    74.5    230.3
28.5    69.5    199.5
32.5    74.5    109.4
31.5    74.5    93.7
38.5    77.5    227.5
27.5    72.5    23.6
29.5    71.5    223.5
30.5    73.5    171.8
34.5    60.5    31.3
29.5    75.5    197.6
30.5    75.5    121.7
27.5    68.5    255.7
33.5    71.5    94.4
28.5    70.5    252.7
30.5    74.5    119
26.5    70.5    537
27.5    70.5    184.5
23.5    70.5    519.5
29.5    70.5    212.6
38.5    78.5    75.3
23.5    69.5    464.5
28.5    76.5    228.5
34.5    61.5    56.5
26.5    69.5    419.2
27.5    77.5    210.9
31.5    70.5    154
25.5    68.5    322.4
27.5    78.5    180.2
31.5    75.5    111.2
23.5    71.5    487.1
26.5    71.5    405
24.5    71.5    442.2
34.5    71.5    101.4
28.5    78.5    153
24.5    70.5    306.6
28.5    77.5    145.9
25.5    71.5    460.1
25.5    70.5    406.4
27.5    69.5    344.8
25.5    69.5    352.8
26.5    68.5    313.1
26.5    77.5    201.6
27.5    73.5    144.2
30.5    76.5    130.7
29.5    76.5    149
33.5    73.5    67.1
22.5    70.5    440.6
22.5    69.5    295.7
22.5    71.5    440.3
25.5    67.5    230.7
29.5    77.5    150.7
24.5    69.5    394.8
22.5    72.5    409.2
26.5    72.5    272
23.5    72.5    477.2
26.5    67.5    141.9
24.5    72.5    376.8
26.5    76.5    158.8
29.5    78.5    152.2
25.5    72.5    331.3
30.5    70.5    89.8
27.5    74.5    384.6
23.5    73.5    372.3
33.5    61.5    14.3
26.5    73.5    230.3
27.5    76.5    160.2
26.5    78.5    113
25.5    78.5    311.7
30.5    77.5    51
25.5    74.5    141.1
26.5    74.5    172.7
27.5    67.5    97.9
22.5    74.5    292.9
23.5    78.5    88
31.5    76.5    85.2
24.5    73.5    142.1
26.5    75.5    115.9
27.5    75.5    201.5
25.5    76.5    145
25.5    73.5    203.2
24.5    74.5    214.4
23.5    74.5    269.9
24.5    76.5    192
24.5    75.5    199.5
27.5    60.5    29.4
22.5    76.5    87.9
24.5    78.5    184.6
28.5    67.5    22
22.5    73.5    496.8
23.5    75.5    218.8
31.5    65.5    17.6
22.5    77.5    216.6
23.5    77.5    167.3
26.5    60.5    42.3
26.5    65.5    14.9
22.5    78.5    119.4
31.5    66.5    150.7
34.5    67.5    3386.3
32.5    63.5    0
36.5    63.5    0
36.5    64.5    0
35.5    62.5    0
36.5    62.5    0
36.5    60.5    0
36.5    72.5    0
36.5    73.5    0
38.5    72.5    0
36.5    74.5    0
37.5    73.5    0
38.5    73.5    0
37.5    74.5    0
34.5    76.5    0
30.5    61.5    0
25.5    61.5    0
33.5    76.5    0
35.5    76.5    0
25.5    65.5    0
34.5    77.5    0
25.5    62.5    0
25.5    64.5    0
24.5    67.5    0
31.5    78.5    0
25.5    63.5    0
36.5    78.5    0
36.5    75.5    0
36.5    76.5    0
33.5    77.5    0
36.5    77.5    0
26.5    61.5    0
26.5    62.5    0
32.5    77.5    0
34.5    78.5    0
33.5    78.5    0
32.5    78.5    0
32.5    72.5    0
35.5    77.5    0
35.5    78.5    0
22.5    75.5    0
27.5    61.5    0
34.5    63.5    0
38.5    68.5    0
38.5    69.5    0
38.5    67.5    0
36.5    69.5    0
32.5    61.5    0
38.5    70.5    0
37.5    70.5    0
35.5    64.5    0
33.5    70.5    0
32.5    75.5    0
33.5    62.5    0
36.5    70.5    0
32.5    65.5    0
35.5    66.5    0
29.5    67.5    0
35.5    68.5    0
37.5    76.5    0
33.5    74.5    0
34.5    73.5    0
38.5    75.5    0
35.5    65.5    0
35.5    69.5    0
31.5    69.5    0
27.5    65.5    0
34.5    70.5    0
29.5    66.5    0
32.5    76.5    0
28.5    66.5    0
32.5    69.5    0
32.5    66.5    0
33.5    65.5    0
34.5    69.5    0
35.5    67.5    0
33.5    63.5    0
32.5    67.5    0
35.5    71.5    0
31.5    68.5    0
33.5    75.5    0
31.5    67.5    0
31.5    77.5    0
34.5    65.5    0
30.5    67.5    0
32.5    68.5    0
33.5    69.5    0
33.5    66.5    0
34.5    64.5    0
35.5    72.5    0
32.5    64.5    0
33.5    67.5    0
33.5    68.5    0
34.5    68.5    0
34.5    74.5    0
32.5    70.5    0
37.5    71.5    0
34.5    66.5    0
35.5    70.5    0
35.5    73.5    0
34.5    75.5    0
34.5    72.5    0
32.5    62.5    0
38.5    74.5    0
38.5    71.5    0
26.5    64.5    0
26.5    66.5    0
30.5    69.5    0
33.5    64.5    0
29.5    61.5    0
30.5    68.5    0
30.5    78.5    0

& this is the image (shape file here not uploading that why i share image here) enter image description here

& what i want is shown one of the maps shown below enter image description here

1 Answers1

0
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