I need to extract latitude and longitude from geotiff file

28 visualizaciones (últimos 30 días)
Aswathi VK
Aswathi VK el 2 de Mayo de 2024
Comentada: Aswathi VK el 3 de Mayo de 2024
I am working with SMAP soil moisture data of downscaled product of 1km. The image is in geotiff format, i couldnt extract latitude and longitude value for the data, while visualising the image the x and y axis appears to be row and coloumn number. Please help me for the same
matlab version: MATLAB R2019a
geotiff file: NSIDC-0779_EASE2_G1km_SMAP_SM_DS_20160101.tif

Respuestas (1)

Sachin Lodhi
Sachin Lodhi el 2 de Mayo de 2024
Hello Aswathi,
I understand that you want to extract latitude and longitude from geotiff file in Matlab R2019a. For achieving this, you can use the following workaround :
[A,R] = readgeoraster('inputFile.tif');
[x,y] = pixcenters(R, size(A), 'makegrid');
info = geotiffinfo('inputFile.tif');
[lat,lon] = projinv(info,x,y);
figure
geoshow(lat,lon,A);
xlabel('Longitude (degrees)')
ylabel('Latitude (degrees)')
Moreover, to fit the figure's axes to exactly match the size of the geotiff file, use the following code in addition to the above snippet :
xlimits = R.XWorldLimits;
ylimits = R.YWorldLimits;
[latlim,lonlim] = projinv(info,xlimits,ylimits); % if using 2021a or later, use 'R.ProjectedCRS' instead of 'info'
xlim(lonlim);
ylim(latlim);
I hope this helps!
  1 comentario
Aswathi VK
Aswathi VK el 3 de Mayo de 2024
Thank you very much for the quick reply. I tried using that and unfortunately it does not work. This is proving to be quite a difficult problem for me.

Iniciar sesión para comentar.

Categorías

Más información sobre Reference Applications en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by