How to specify geotiff coordinate if the RefMatrix is empty?

Hello,
I would like to know how I can visualize and extract the lat-lon information from my geotiff file. When I use the geotiffinfo, it appears that my file coordinate are from 0 to 360 degrees since I opened in ArcGIS and the extent are Top: 19.10, Right: 283.72, Bottom: 6.82 and left: 267.35. I would like to extract the lat and long values in the other format (e.g. -92.64, 6.82)
Additionally, the RefMatrix variable in the Geotiffinfo function appears empty.
The geotiff file is attached in this question

 Accepted Answer

tiffile = 'lluvia_15.tif' ;
[A, R] = geotiffread(tiffile);
[nx,ny] = size(A) ;
S = geotiffinfo(tiffile) ;
L = S.GeoTIFFTags.ModelTiepointTag ;
lons = L(:,4) ; lats = L(:,5) ;
min_lon = min(lons) ; max_lon = max(lons) ;
min_lat = min(lats) ; max_lat = max(lats) ;
image([min_lon max_lon],[min_lat max_lat],A)

3 Comments

Thank you KSSV
It works perfectly. However, I am still struggling on the lat and long coordinate format. I do not want the coordinate in the [0° to 360°] format
Additionally, Is there any way to obtain coordinates vector for each cell? I mean, when you use the pixcenter function, you obtain the lat and long of each cell of the geotiff file. In the example provided, I only have the max and min extent of the coordinates
dx = (max_lon-min_lon)/(nx-1) ;
dy = (max_lat-min_lat)/(ny-1) ;
x = min_lon:dx:max_lon ;
y = min_lat:dy:max_lat ;
Thanks... It creates the vector that contains the information that I wanted. However, when I plot the geotiff file vs. a shapefile, the latter show the polygon upside down. After reviewing the plot, i realized that the shapefile is correct and the geotiff plot is not, since the y-axis has to be from 8 to 18 and not from 18 to 8
Here is the code that I used for that
x = wrapTo180(x) % Wrap angle in degrees to [-180 180]
image(x,y,A)
hold on
ES = shaperead('centroamerica.shp', 'usegeocoords', true);
geoshow([ES.Lat],[ES.Lon], 'Color','k');
You can find attached the shapefile and the geotiff file that I have used
Thank you so much for your answer.

Sign in to comment.

More Answers (0)

Products

Release

R2016a

Asked:

on 4 Sep 2018

Edited:

on 9 Sep 2018

Community Treasure Hunt

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

Start Hunting!