Matlab仅冲浪点,而不是线

时间:2015-06-20 12:33:12

标签: matlab

我必须在3D图上绘制一个逼真的地图。我有两个向量1x401(名为xLabelsyLabels) which are the geo coordinates, and 401x401 (named A`)矩阵与高度数据。绘制我使用的数据:

surf(xLabels, yLabels,A,'EdgeColor','None','Marker','.');

导致类似的事情:

bad picture

但我希望有类似的东西:

how it should look like

在第二张图像上,仅绘制表面,而我的图像看起来像柱子。

我尝试使用401x401将我的向量设为meshgrid,但它没有任何效果。

你知道我应该改变什么吗?

@EDIT

我检查了X和Y数据。我的间隔太小(0.0083),但是当我尝试以相同的间隔绘制好的第二个上图时,它会正确绘制。

@ EDIT2:

sizeX = 4800;
sizeY = 6000;
pixdegree = 0.0083; % 1 pixel is 0.0083 degree on map
intSize = 2;
lon = 37 + (35/60);
lat = 55+ (45/60);
fDEM = 'E020N90';
fHDR = 'E020N90.HDR';
[startXY, endXY] = calcFirstPixel(lon, lat); %calc borders for my area
f = fopen('E020N90.DEM');
offset = (startXY(1,2)*sizeX*intSize)+(startXY(1,1)*intSize);
fseek(f, offset,0); %seek from curr file pos
x = 0;
A = [];
BB = [];
jump = (intSize*sizeX)-(401*2);
while x<401
    row = fread(f, 802);
    fseek(f, jump, 0); %jump 2 next row
    A = [A row];
    x = x+1;
end
fclose(f);
A = A';
A = A(:,2:2:802);
m1 = min(A(:)); %wartość minimalna dla naszej podziałki
m2 = max(A(:)); %wartość maksymalna dla naszej podziałki
step = m2/8; % będzie 8 kolorów
highScale = m1:step:m2-step; %wartości graniczne dla każdego z nich
%handles.axes1 = A;
colormap(hObject, jet(8));
startXtick = 20 + pixdegree*startXY(1,1);
endXtick = 20 + pixdegree*endXY(1,1);
startYtick = 90 - pixdegree*endXY(1,2);
endYtick = 90 - pixdegree*startXY(1,2);
[XX,YY] = ndgrid(startXtick:pixdegree:endXtick,startYtick:pixdegree:endYtick);
xLabels = startXtick:pixdegree:endXtick;
yLabels = startYtick:pixdegree:endYtick;
surf(xLabels, yLabels,A,'EdgeColor','None','Marker','.');
set(gca,'YDir','normal');
grid on;
view([45 45])

.DEM files

function [startXY, endXY] = calcFirstPixel(lon,lat)
    global fHDR;

    format = '%s %s';
    f = fopen(fHDR);
    cont = textscan(f, format);
    LonStart = str2double(cont{1,2}{11,1});
    LatStart = str2double(cont{1,2}{12,1}); 
    diffPerPix = str2double(cont{1,2}{13,1});
    fclose(f);
    x = LonStart;
    countX = 0
    y = LatStart;
    countY= 0;
    while x<lon
        x=x+diffPerPix
        countX = countX +1;
    end
    while y>lat
        y=y-diffPerPix
        countY = countY+1;
    end
    startXY= [countX-200 countY-200];
    endXY = [countX+200 countY+200];
end

0 个答案:

没有答案