Why am I getting "Unable to read file 'topo60c'. No such file or directory" error in Matlab?

Viewed 55

Many of Matlab's Mapping toolbox examples require "topo60c" world map data. Here's an example

load topo60c
axesm hatano
meshm(topo60c,topo60cR)
zlimits = [min(topo60c(:)) max(topo60c(:))];
demcmap(zlimits)
colorbar

However, when I run the above script, Matlab displays a file not found error for "topo60c". Does anyone know why I'm getting this error? I have the Mapping toolbox installed, and it works with other Mapping sample code that doesn't reference that file.

1 Answers

In the acknowledgements section of the mapping toolbox docs there is a note about example data sources:

https://uk.mathworks.com/help/map/dedication-and-acknowledgment.html

Except where noted, the information contained in example and sample data files (found in matlabroot/examples/map/data and matlabroot/toolbox/map/mapdata) is derived from publicly available digital data sets. These data files are provided as a convenience to Mapping Toolbox™ users. MathWorks® makes no claims that any of this data is free of defects or errors, or that the representations of geographic features or names are up to date or authoritative.

You can open these folders from MATLAB (on Windows) using

winopen( fullfile( matlabroot, 'examples/map/data' ) )
winopen( fullfile( matlabroot, 'toolbox/map/mapdata' ) )

Or simply use the fullfile commands above to identify the paths and navigate there yourself.

I can see (MATLAB R2020b) the topo60c file within the first of these folders, which isn't on your path by default because it's within "examples" and not a toolbox directory:

file

So you could either:

  1. Add this folder to your path so that MATLAB can see the file: addpath(fullfile(matlabroot,'examples/map/data'));

  2. Reference the full file path to the data when running examples: load(fullfile(matlabroot,'examples/map/data/topo60c.mat'));

I would prefer option 2 to avoid changing the path.


Additionally, there is another note in the Raster Geodata section of the docs which details what that dataset should contain

https://uk.mathworks.com/help/map/raster-geodata.html

When raster geodata consists of surface elevations, the map can also be referred to as a digital elevation model/matrix (DEM), and its display is a topographical map. The DEM is one of the most common forms of digital terrain model (DTM), which can also be represented as contour lines, triangulated elevation points, quadtrees, octree, or otherwise.

The topo60c MAT-file, which contains global terrain data, is an example of a DEM. In this 180-by-360 matrix, each row represents one degree of latitude, and each column represents one degree of longitude. Each element of this matrix is the average elevation, in meters, for the one-degree-by-one-degree region of the Earth to which its row and column correspond.

Given that it's generated from publically available data anyway (ref the first docs quote) and you now know what data it represents (ref the 2nd docs quote), you could replicate some replacement data if really needed.

Related