Clear Filters
Clear Filters

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

2 views (last 30 days)
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 Comment
Patrick Tully
Patrick Tully on 21 Nov 2020
Did you ever find the solution to this problem ? I'm struggling with the same issue myself!

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!