As underdark pointed out, you are running out of RAM. How much RAM do you have? 64 bit system or 32 bit?
SAGA GIS always puts all datafiles completely in memory. This is one of the reasons why it is so fast, but it fails on huge files.
Things you could do to:
- Increase the grid resolution to eg 200m.
- You may also try to run the command directly from the command line or saga gui, when qgis is not taking up memory.
- If you do require full resolution and the above solutions don't work you could try enabling file cache in saga gui (you will have to run through gui, afaik this is not supported in saga_cmd): in the manager window click the data tab and click again on data in the top of the tree. In the settings window you should now find an option "grid file caching". You can enable automatic mode here. Performance may be very poor when doing so. I'd really recommend increasing the grid resolution if that is an option.
I think it is bug in index.js. I just replicate what you did but differently, and got to the same result:
I run index.js in a .hgt file, then replaced the "],[" by new lines and removed any extra "[" or "]" doing
cat heights.json | sed 's/\],\[/\n/g' | tr -d ']' | tr -d '[' > heights.csv
Then loading the csv in matlab in fact produced an error of inconsistency in the number of columns per row.
By counting the number of commas per line using:
sed 's/[^,]//g' heights+cr.txt | awk '{ print length }'
It indeed show that the first row has 1202 columns, the last 1200 columns and all the rest 1201 columns.
However, after loading the same .htg file directly in Matlab, it produce a nice 1201x1201 matrix.
You can load it directly in Matlab with the following code:
fileID=fopen('S40W067.hgt','r');% Replace by your HTG file
data = fread(fileID,[1201,1300],'uint16',0,'b');
fclose(fileID);
If you rather python, this question show some code examples.
By looking at the data from index.js and from Matlab, it seem that if you move the extra element at the end of row one, to be the first of row two, and then the last of two to be the first of the third row and so on, you will end up with the correct 1201x1201 data matrix.
Best Answer
You can use "gdal_translate" from GDAL to convert the HGT files for example to GeoTIFF format.
For example: