如何在matlab中的颜色图上标记形状文件

时间:2015-07-26 15:35:38

标签: matlab mapping matlab-guide shapefile colormap

我正在尝试从文本文件数据制作颜色映射。我使用geoshow调用区域的形状文件并将其设置为颜色贴图的背景。我的形状文件属于国家/地区。我把它的区域数字化为多边形。在形状文件的属性中,我在“NAME_1”字段下命名了这些区域。我正在使用该代码制作颜色映射

fid = fopen('1000_2000.txt');
 C = textscan(fid, '%f %f %f')
 fclose(fid);
 f = {'lat', 'long', 'temp'}
 S = cell2struct(C,f,2);
 N = 100;
 [Xi, Yi] = meshgrid(linspace(60,80,N),linspace(20,40,N));
 Ci = griddata(S.long, S.lat, S.temp, Xi, Yi);
 f = figure; set(f, 'Renderer', 'painters')
 colormap default
  h = geoshow(Yi,Xi,Ci,'DisplayType','surface');
 set(h,'ZData', zeros(size(get(h,'XData'))));
 p = geoshow('PAK_adm1.shp', 'DisplayType','polygon','FaceColor','none','EdgeColor','w');
 xlim([60.5 78.5]);
ylim([22.5 38.5]);
xlabel('Longitude');
ylabel('Latitude');
set(gca,'CLim',[0,3000])
 colorbar

我的输出为

enter image description here

我想要这种标签功能(想要在形状文件的属性中用字段名称NAME_1显示标签)

enter image description here

我不是一个大程序员。不知道如何更正这些代码来标记我的彩色地图上的功能?在此先感谢您提供此类帮助

1 个答案:

答案 0 :(得分:0)

>>a=axes;

>>S = shaperead('landareas','UseGeoCoords',true);

>>geoshow([S.Lat], [S.Lon],'Color','black');

>>text(-125,50,'America')