Clear Filters
Clear Filters

Error using readgeoraster??

4 views (last 30 days)
Nihal
Nihal on 27 Jun 2024
Answered: Shubham on 28 Jun 2024
file1 = 'path/to/first/raster.tif';
file2 = 'path/to/second/raster.tif';
file3 = 'path/to/third/raster.tif';
raster1 = readgeoraster(file1);
Error using readgeoraster (line 61)
Unable to find or open 'path/to/first/raster.tif'. Check the path and filename or file permissions.
I try to file upload and slope analysis but ı got this error. Can you help me with this prob?

Answers (1)

Shubham
Shubham on 28 Jun 2024
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:
  1. 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:
% Define the absolute paths to the raster files
file1 = 'C:/path/to/first/raster.tif';
file2 = 'C:/path/to/second/raster.tif';
file3 = 'C:/path/to/third/raster.tif';
% Check if the files exist
if exist(file1, 'file') == 2 && exist(file2, 'file') == 2 && exist(file3, 'file') == 2
% Read the raster files
raster1 = readgeoraster(file1);
raster2 = readgeoraster(file2);
raster3 = readgeoraster(file3);
% Perform slope analysis
else
error('One or more files do not exist. Please check the file paths.');
end
I hope this helps!

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!