Hi Nihal,
The error message you're encountering indicates that MATLAB is unable to locate or open the specified file. This can happen for several reasons, including incorrect file paths, missing files, or insufficient permissions. Below are steps to troubleshoot and resolve the issue:
Step-by-Step Troubleshooting:
- Verify File Paths:
- Ensure that the file paths specified are correct and that the files exist at those locations.
- Use absolute paths instead of relative paths to avoid path issues.
2. Use MATLAB's File Browser:
- In MATLAB, use the Current Folder browser to navigate to the directory containing your raster files.
- Right-click the file and select "Copy Full Path" to ensure you are using the correct path.
Example Code with Absolute Paths:
file1 = 'C:/path/to/first/raster.tif';
file2 = 'C:/path/to/second/raster.tif';
file3 = 'C:/path/to/third/raster.tif';
if exist(file1, 'file') == 2 && exist(file2, 'file') == 2 && exist(file3, 'file') == 2
raster1 = readgeoraster(file1);
raster2 = readgeoraster(file2);
raster3 = readgeoraster(file3);
error('One or more files do not exist. Please check the file paths.');
I hope this helps!