In the USGS Spectroscopy laboratory, the researchers there have worked very hard to measure reflectance of a hundreds of minerals (and plants).

Look at this site

I downloaded the splib04a - FTP Compressed Binary but I don't know how to access its entries in MATLAB.

How can one read and access every spectrum in this spectral library?


Besides relevant UNIX commands, I believe that a *.Z file can be uncompressed using the 7zip application. Besides that, the files are just space separated ASCII files. If you do not need the entire library you could just assess the FTP site with the individual uncompressed ASCII files and download the desired spectra.

The "spc" file extension is arbitrary and does not correspond to any given specialized format. You can look at the data structure by going directly to the file. Here is a-alunit.spc, which contains four columns: "Ammonioalunite", "NMNH145596", "W1R1Bd", "ABS REF" with their associated numeric values. These files can be manually downloaded or accessed using various functions in MATLAB (eg., ftp). The function to read delimited ASCII files in MATLAB is tdfread.

EDIT: as with many USGS databases, this one is very confusing with apparent redundancy containing different data. I stumbled across a different ftp location for splib06 that contains what appears to be the correct spectral scales, containing: "wavelength", "reflectance", "standard deviation" and are *.asc files.

Accessing the "a-alunit.spc" file directly, via the commandline, in MATLAB would look something like this:

usgs = ftp('ftpext.cr.usgs.gov')
cd(usgs, 'pub/cr/co/denver/speclab/pub/spectral.library/splib04.library/ASCII.FILES')
type a-alunit.spc 
  • thank you for your answer:) Yes In fact I just need few desired spectra and so I also accessed this link but I didn't know how to read the spc format. Lets say the first one, that is, a-alunit.spc, do you have any idea of how to access to this spectra in MATLAB? Your help will be very appreciated. – Christina Nov 22 '16 at 21:21
  • Like I mentioned, they are just space (or perhaps tab) separated ASCII files. It took me 5 seconds to read the first "a-alunit.spc" file in R, directly from the ftp site. You can look that the contents using a text editor or importing text to columns in Excel. MATLAB readily imports space separated ASCII files. – Jeffrey Evans Nov 22 '16 at 21:28
  • While I am compiling your code, I am getting an error: Error using connect (line 18) Could not open a connection to "ftpext.cr.usgs.gov", port "21". – Christina Nov 22 '16 at 22:29
  • Please see my edit to the answer. – Jeffrey Evans Nov 22 '16 at 23:18
  • Yea!! finally I got the plot of a spectrum. I just copied the three columns as a matrix in matlab, and then I used the second column (without the first two values which are very high). But there is no an automatic function that can read directly the ascii file? – Christina Nov 22 '16 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.