Direct-access binary files
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mattia Albertini
le 8 Mar 2020
Commenté : Walter Roberson
le 9 Mar 2020
Hi,
I need to upload a dataset on MatLab for research purposes, and the best dataset I was able to find apparently is formatted as a direct access binary file, here it comes:
Data files are written as direct-access binary files.
Infofile description:
Row 1 longitude resolution (XSTEP)
Row 2 latitude resolution (YSTEP)
Row 3 number of rows (NROWS)
Row 4 number of columns (NCOLS)
Row 5 no data code (NODATA)
Row 6 longitude of the central point of the upper left grid box (ULXCUT)
Row 7 latitude of the central point of the upper left grid box (ULYCUT)
Row 8 record length in bytes (BANDROWBYTES)
Row 9 file name
Now, my question is extremely simple: How do I extract all the informations contained here in a table? With the current information I found online I wasn't able to do anything.
3 commentaires
Walter Roberson
le 8 Mar 2020
To confirm, the .inf file is a text file that describes the corresponding file that does not have an extension?
Réponse acceptée
Walter Roberson
le 8 Mar 2020
The .inf file appears to be a text file. Read the first 8 rows of it as numbers and assign to appropriate variables.
After that you would probably use https://www.mathworks.com/help/matlab/ref/multibandread.html multiband read. Offset would be 0. I suspect that precision is 'single'. Difficult to guess whether it is big-endian or little-endian. bands is probably 1. It is not immediately clear whether the data is in row-major order or column-major order so it is not clear whether you should use [nrows, ncols] or [ncols, nrows] as the size parameter.
I am not sure at the moment what the bandrowbytes would do for you... unless, that is, there are multiple bands
Can you show us a sample .inf file, and show us the size of the corresponding binary file?
My suspicion is that the "no data code" is the value that is stored in the file to indicate that no data is available at that location.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!