Re: ENVI Question: Can you programmatically access the Available Spectra List? [message #53190] |
Fri, 30 March 2007 07:37  |
Jeff N.
Messages: 120 Registered: April 2005
|
Senior Member |
|
|
> I confess (sheepishly) to never having worked with spectral libraries.
> But they are just like ENVI images that you can access programmatically
> with, e.g., ENVI_GET_DATA. For example the USGS Vegetation Spectral
> Library is a single band image with 17 lines (the different spectra) and
> 420 samples (the data). So if you have a library in your available bands
> list with file id FID and spatial subset DIMS, then
>
> spectra = envi_get_data( fid=fid, dims=dims, pos=0 )
>
> will put the whole thing into the IDL variable SPECTRA, and you can do
> _anything_ you want with it.
>
> Cheers
>
> Mort
Hi Mort,
Thanks for the reply. I knew about getting data out of spectral
libraries already - I think I probably didn't explain my original
problem well enough. Lets say you had a z-profile (or any kind of
profile, really) opened in an ENVI spectral profile window. If you
then go to spectral math and enter an expression like "s1 + 50" in the
expression dialog, then the next thing you're going to see is another
dialog where you tell ENVI which spectrum you're going to use as s1.
That spectrum that you had in the ENVI spectral profile window is
going to be listed in that dialog box so that you can tell ENVI to use
it as s1. In fact, if you didn't have a spectral profile window up
with any spectra displayed before you called the spectral math dialog,
the spectral math dialog will give you an error as I recall. It does
all this by somehow having a list in memory of all the spectra that
are being displayed in a profile box. What I want to do is get to
that list and use it in a routine of my own. That way I can process on
any kind of spectrum, whether it be from a library, a remote sensing
scene, test data, etc.
I'm sure you know that there are custom "plot functions" that you can
write that show up under the "Plot Function" menu of a spectral
profile display if you modify the useradd.txt file. But, like with
custom band and spectral math functions, the code that you write has
some limitations. This is sort of what I want to do in that it's a
routine that takes in a spectrum that's been displayed in a profile
window and does some things with it. But I need to do more than just
display that input spectrum. I need to do things that require more
input from the user, so I need dialog boxes, etc. Now, of course, I
can write a routine of my own that gets the spectrum from the user
some other way, but that just seems to be reinventing the wheel, and
from the user's point of view it seems more intuitive to display a
routine, and then click a button or something that says "Do Jeff's
nifty routine on this spectrum."
I've pretty much given up hope that what I want to do is possible, but
I thought it was worth a try anyway.
Thanks for your help,
Jeff
|
|
|