No appropriate method, property, or field 'LatitudeLimits' for class 'map.rasterref.MapCellsReference'.
Show older comments
I work with geotiffread to process a tif file. I got this error and don't know how to solve? Please help me. Thank you so much.
I use R2018a.
No appropriate method, property, or field 'LatitudeLimits' for class
'map.rasterref.MapCellsReference'.
Here is the code:
addpath('C:\Users');
addpath('C:\Users\Asus\Documents\MON\OUT_put');
set(0, 'defaultfigurecolor', [1 1 1]);
load('C:\Users\Asus\Documents\MON\Materials monitoring floods\lats.mat');
load('C:\Users\Asus\Documents\MON\Materials monitoring floods\lons.mat');
pixel_number = 500;
%------------------------------------------------------------
%DATA BEFORE
filename_before = 'Water-mask-Tonle-Sap-Lake-2015-03-28.tif';
[A_before, R_s1] = geotiffread(filename_before);
matrix_size = size(A_before);
A_before = bwareaopen(A_before, pixel_number);
surfacewater_map_before = reshape( A_before, [1,matrix_size(1)*matrix_size(2)]);
surfacewater_map_before = double(surfacewater_map_before);
lat_vector = transpose(linspace(R_s1.LatitudeLimits(2), R_s1.Latitudelimits(1), R_s1.RasterSize(1)));
lon_vector = linspace(R_s1.Longtitudelimmits(1), R_s1.Longtitudelimits(2), R_s1.RasterSize(2));
[lon_matrix, lat_matrix] = meshgrid(lon_vector, lat_vector);
lat_ = reshape(lat_matrix, [1, matrix_size(1)*matrix_size(2)]);
lon_ = reshape(lon_matrix, [1, matrix_size(1)*matrix_size(2)]);
water_area_before = round(sum(surfacewater_map_before)*0.01*2);
Answers (1)
Walter Roberson
on 13 Mar 2023
0 votes
Looking at the help for geotiffread():
R: Spatial referencing object, returned as one of the following.
- A geographic raster reference object of type GeographicCellsReference or GeographicPostingsReference. This object is returned when the image or data grid is referenced to a geographic coordinate system.
- A map raster reference object of type MapCellsReference or MapPostingsReference. This object is returned when the image or data grid is referenced to a projected coordinate system.
Now, GeographicCellsReferences and GeographicPostingsReference both do have LatitudeLimits and LongitudeLimits properties. But MapCellsReference and MapPostingsReference do not have those properties.
Categories
Find more on Structured Data and XML Documents in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!