Error: No appropriate method, property, or field...

조회 수: 2 (최근 30일)
Sarah Yun
Sarah Yun 2019년 11월 17일
댓글: Patrick Tully 2020년 11월 21일
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개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by