Importing an ascii file in to matlab
4 ビュー (過去 30 日間)
古いコメントを表示
Hey all,
I am trying to import a rather hefty asc file (12GB) into Matlab (R2012a). It was originally a tif file which I had in ArcGIS as a DEM. I am trying to import it into Matlab to work out the volume between the DEM and a olane I have created using cftool.
When I used M=dlmread(demtest) it comes up with 'Undefined variable "demtest" or function "demtest.asc".'
Does any body have any ideas? I'm pretty new to matlab so English is you please :D Thanks
2 件のコメント
Geoff Hayes
2014 年 4 月 23 日
Hi Katie,
What is demtest defined to be? MATLAB is assuming that it is a local variable (I get the same "Undefined variable" error when I run the line M=dlmread(demtest)).
The function dlmread is expecting its input to be a string to the path and filename. Something like:
fileToRead = '/Users/geoff/Documents/demtest.asc';
Or whatever the full path (and name) is to the file you want to read. Just remember that the input must be a string.
Geoff
回答 (4 件)
dpb
2014 年 4 月 23 日
M=dlmread(demtest) [yields] 'Undefined variable "demtest" or function "demtest.asc".'
Because dlmread is expecting a file name but you didn't enclose the argument in quotes so Matlab thinks demtest is a variable.
Use
M=dlmread('demtest.asc');
instead
0 件のコメント
Katie
2014 年 4 月 23 日
1 件のコメント
Geoff Hayes
2014 年 4 月 23 日
Katie - is it necessary to use all of the data in your 12GB file or can you uses a subset of it instead? I'm not familiar with the arcgridread function but the online documentation says that its input is Arc ASCII Grid format so if you could make this data coarser (reduce the resolution?) you will have a smaller set of data to work with. (I don't know if that is possible though…)
Geoff
Kelly Kearney
2014 年 4 月 23 日
What are the dimensions of your grid? Your probably going to have to divide your grid into smaller blocks to do the calculations.
Most of the Mapping Toolbox functions, like arcgridread, don't play well with large files, since they're designed to read everything in all at once, which as you've discovered can easily exceed memory limits. But arc ascii files follow a simple format, so you should be able to read it in in pieces and perform your calculations without holding the whole file in memory.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!