How to show a .tif file with projected coordinate system in geographic system?

32 visualizaciones (últimos 30 días)
Hello guys, i'm finishing an essay which i need to plot some trajectories points(in lat lon) on a map to do some further analysis. I've now downloaded a .tif file in projected coordinate system. I used
[A,R] = readgeoraster(filename);
mapshow(A,R)
and get the same coordinate system like this example: https://ww2.mathworks.cn/help/map/ref/readgeoraster.html
But what i really need is lat lon corrdinate system. like the image in example 5 here: https://www.mathworks.com/help/map/creating-map-displays-with-data-in-projected-coordinate-reference-system.html
This example 5 requires a .jpg file with geographic data whose coordinates are already in latitude and longitude, which of course i don't have one. I only have the .tfw file along with the .tif file.
So i used the following funtions to extract the lat and lon from the .tif file:
filename = 'G:\SA\Data\dop20c_33412_5654.tif';
[A,R] = readgeoraster(filename);
info = geotiffinfo(filename);
[AY, AX, Z]= size (A);
height = info.Height;
width = info.Width;
[rows,cols] = meshgrid(1:height,1:width);
[x,y] = pix2map(info.RefMatrix, rows, cols);
[lat,lon] = projinv(info, x,y);
And then i get two arrays named lat, lon (10000x10000) with the required latitude and longtitude infomation. But now how can i use these info to plot a new image with these lat and lon?
Or maybe there are other funtions that don't actually need these steps but directly plot the image the way i wanted?
Thank you so much for your help!
  2 comentarios
darova
darova el 28 de Abr. de 2020
Is this the picture you want to get?
Do you have color lines?
Zihan Liu
Zihan Liu el 28 de Abr. de 2020
no the one with lat and lon is what i want. I don't have any color lines.
This is what i get after using mapshow(A,R):

Iniciar sesión para comentar.

Respuestas (2)

darova
darova el 29 de Abr. de 2020
As i understood you correctly: you want to have grid line/dots on your image
Here is an example
A = zeros(100); % 2d zero matrix
[X1,X2] = meshgrid(10:20:90, 1:4:99); % grid
ind1 = sub2ind(size(A),X1(:),X2(:)); % horizontal
ind2 = sub2ind(size(A),X2(:),X1(:)); % vertical
A(ind1) = 1;
A(ind2) = 1;
imshow(A)
  3 comentarios
darova
darova el 29 de Abr. de 2020
Use Xtick and Xticklabel
xx = 0:20:100;
set(gca,'xtick',xx)
set(gca,'ytick',xx)
s1 = strsplit(sprintf('%dW\n',xx));
s2 = strsplit(sprintf('%dN\n',xx));
set(gca,'xticklabel',s1)
set(gca,'yticklabel',s2)
Zihan Liu
Zihan Liu el 29 de Abr. de 2020
Thanks a lot for your ideas, but i'm sorry it's not directly linked to my problem. It's a relative more complicated case.... I think it requires some funtions from Mapping Toolbox.

Iniciar sesión para comentar.


Geraldine Maria Palacios Torres
Geraldine Maria Palacios Torres el 28 de Oct. de 2021
Hi Liu
I am facing the same issue. I cannot display the image in its geographical coordinates
I wonder if you figured it out?

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by