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
Patrick Tully 2020-11-21
Did you ever find the solution to this problem ? I'm struggling with the same issue myself!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by