How to specify geotiff coordinate if the RefMatrix is empty?

4 views (last 30 days)
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

KSSV
KSSV on 5 Sep 2018
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
KSSV
KSSV on 6 Sep 2018
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 ;
Jose Valles
Jose Valles on 9 Sep 2018
Edited: Jose Valles on 9 Sep 2018
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

Community Treasure Hunt

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

Start Hunting!