Error: No appropriate method, property, or field...
5 次查看(过去 30 天)
显示 更早的评论
Hi,
I get the following error when trying to calculate area of land in two landsat images (NDVI and NDWI) covered by vegetation.
'No appropriate method, property, or field 'SampleSpacingInWorldX' for class 'map.rasterref.MapCellsReference'.'
Please help.
Here is the code.
Whay is causing the error?
%% Combine NDWI and NDVI to calculate proportion of the land covered with vegetation
% Load the NDVI and NDWI tif
NDVI = geotiffread...
('../data/NDVI.tif');
info = geotiffinfo...
('../data/NDVI.tif');
NDWI = geotiffread...
('../data/NDWI.tif');
%% Set thresholds
NDVI_threshold = 0.4;
NDWI_threshold = 0.075;
%% Apply thresholds
veg = (NDVI >= NDVI_threshold);
water = (NDWI >= NDWI_threshold);
land = (NDWI < NDWI_threshold);
% Find areas of land and vegetation
land_veg = (NDVI >= NDVI_threshold & NDWI < NDWI_threshold);
% Get number of pixels of different surfaces
tot_px = numel(NDVI);
land_px = sum(land(:));
land_veg_px = sum(land_veg(:));
[ERROR AT NEXT STEP]
% Find percentage of land covered with vegetation
cell_area = (info.SpatialRef.SampleSpacingInWorldX.*...
info.SpatialRef.SampleSpacingInWorldY)./1000000; % (km^2
[No appropriate method, property, or field 'SampleSpacingInWorldX' for class
'map.rasterref.MapCellsReference']
1 个评论
Patrick Tully
2020-11-21
Did you ever find the solution to this problem ? I'm struggling with the same issue myself!
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!