How to read the X,Y and Z coordinates from a TIFF image extracted into Matlab?

I have extracted a TIFF image into Matlab using the geotiff function [A, R] = geotiffread(filename). Now the image is stored for example in A. I want to extract the X,Y and Z coordinates from this image and plot it later using surf function. How do I achieve this?
Thanks for any inputs or pointers

 Accepted Answer

Here are the x and y coordinates of a geotiff:
I = geotiffinfo(filename);
[x,y]=pixcenters(I);
2022 Update - The function pixcenters will be removed in a future release. Use the worldGrid functions instead.

6 Comments

Hi, Thanks for the answer. But I also have to plot the height function which is stored in Z. How do I extract the height information so that I can use it in surf like surf(x,y,z).
What information is in each pixel of your geotiff? Is it height? If so,
z = geotiffread(filename);
I = geotiffinfo(filename);
[x,y]=pixcenters(I);
Otherwise, you'll have to get z from somewhere else, like a geoid or whatever height you're using.
Yes, exactly. In the geotiff image is the height information as well. After extracting the x,y and z do you know how to plot it like a 3D plot which shows a conical projection corresponding to the height present in the geotiffimage (for example height of a tree in the image). I used this function to plot.
surfc(x,y,z);
axis tight;
But all I'm getting is a blank plot like the one shown in the image I've uploaded. The point where the tree is present must be shown as a height and not a contour. Thanks for any Information
I was able to get the correct plot after changing the Matlab version! Thanks again for your help and time
Hi Chad,
Would you know how to replace the 'pixcenters' function to get the x and y coordinates of a georeferenced image?
I used to call this function in 'geoimread', but calling the 'worldGrid' that you advised here does not work.
Best, Dd

Sign in to comment.

More Answers (1)

hello sir can u plz send me the code that hp ow u find the x y and z axis of an image

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Asked:

on 18 Mar 2017

Commented:

dd
on 1 May 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!