1
votes

I have obtained the latitude, longitude and height information from a TIFF image into Matlab and plotting it using the surfc function as surfc(X,Y,Z).

surfc output:

surfc output

Image of the tree: image of tree

But how do I get Z to display as a contour (something like a cone) corresponding to the height of an object in the image?

Thanks for any answers

2
Is there height (altitude) information stored for each pixel of the TIFF image? Is the height of the pixel code in the color of each pixel some how? Is there a height information of each tile? Normally there is a single height information for entire image, so you can't use it for display contour. - Rotem
Hi, Yes. The height information is stored in the geotiff image itself. I'm using the surf function but all I'm getting is a blank plot with only the coordinates. Actually I wanted to plot the height of a tree contained in the geotiff image. - Sack11
Could you provide us a minimal reproducible example - Yvon
@Yvon I'm using these two codes. 'surfc(x,y,z); axis tight'. But after plotting I'm getting a blank plot with the x,y and z. I want the height information to be displayed/plotted corresponding to the height of a tree in the geotiff image - Sack11
Unfortunately we don't have the geotiff image. - Yvon

2 Answers

0
votes

You can change the color mapping of the surf. Example:

clear;clc;close all
tif4 = imread('RzwK3.tif');
THeight = rgb2gray(tif4(:,:,1:3));
imshow(THeight)

x = 1:size(THeight,1); % can be changed to coordinates
y = 1:size(THeight,2);
[X,Y] = ndgrid(x,y);

% make contour color on the surface
M = 4; % # color in contour
Cvec = parula(M); % any Mx3 RGB triplet
hs = surf(X,Y,THeight,'EdgeAlpha',.1);
colormap(Cvec)
colorbar

If parula or other color generation function is not available in your Matlab version, you can assign Cvec manually. Each row of the matrix is a RGB color triplet with values between 0 and 1 (you can divide a web RGB color by 256) and there should be M rows in the matrix. Example: the following is the output of parula(4), which can be manually input by replacing the line of code.

Cvec = [
    0.2081    0.1663    0.5292; % R1 G1 B1
    0.0265    0.6137    0.8135; % R2 G2 B2
    0.6473    0.7456    0.4188; % R3 G3 B3
    0.9763    0.9831    0.0538]; %R4 G4 B4

example output

0
votes

If you have the pionts as cartesian coordinates use plot3

plot3(X,Y,Z,'.');

If X and Y are the independent variables and Z the dependent one (The corresponding height for a given X and Y) then use surf or mesh

surf(X,Y,Z);
mesh(X,Y,Z);

Otherwise put some sample of your data and results so we can better understand your problem.

EDIT: You are actually obtaining a contour plot, but surfc should also plot the surface. Take a look at the documentation of surfc and you will see that it combines two plots in one figure (the surface and the contour)

[X,Y,Z] = peaks(30);
figure
surfc(X,Y,Z)

enter image description here