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

3 visualizaciones (últimos 30 días)
Sarah Yun
Sarah Yun el 17 de Nov. de 2019
Comentada: Patrick Tully el 21 de Nov. de 2020
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 comentario
Patrick Tully
Patrick Tully el 21 de Nov. de 2020
Did you ever find the solution to this problem ? I'm struggling with the same issue myself!

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by