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
|
|
|
Re: ENVI Question: Can you programmatically access the Available Spectra List? [message #53196 is a reply to message #53190] |
Fri, 30 March 2007 00:07   |
Mort Canty
Messages: 134 Registered: March 2003
|
Senior Member |
|
|
Jeff N. schrieb:
> Hi Mort,
>
> I already knew about your book :-) I was a TA for a remote sensing
> class in grad school last year and recommended to the prof. for that
> class that he use your book as his textbook. I still haven't gotten a
> copy for myself yet, but he has and he did say he liked it. So, in
> your book do you answer my question? I've looked everywhere for a way
> to get at this list but couldn't find it.
>
> Jeff
>
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
|
|
|
|
Re: ENVI Question: Can you programmatically access the Available Spectra List? [message #53267 is a reply to message #53190] |
Fri, 30 March 2007 13:34  |
Mort Canty
Messages: 134 Registered: March 2003
|
Senior Member |
|
|
Jeff N. schrieb:
>
> 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
>
Thanks for the explanation. Now I see what you want ( I hope :-) ). I
don't have a clue either, but it seems to me like writing, for instance,
your own ENVI "user defined motion routine" to pick up mouse clicks from
an opened image display, extracting the Z-profiles (or whatever) and
then doing your nifty routine is re-inventing the wheel. You could even
call it from the TOOLS/PROFILES menu. But I guess it's a matter of how
versatile and "envi-like" you want it to be. If you manage to figure it
out after all, let me know.
Cheers
Mort
|
|
|
Re: ENVI Question: Can you programmatically access the Available Spectra List? [message #53280 is a reply to message #53190] |
Fri, 30 March 2007 09:21  |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
> 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.
If you want to use this list, why not simply writing a little function
that you use in the spectral maths? The parameters of this function
would be s1, s2 etc... and the dialog box you are talking about will
show up asking you which spectrum is s1 etc.
Otherwise, maybe the spectrum are accessible through ENVI_SELECT and
ENVI_GET_FILE_IDS .... but I have never tried it!
Jean
>
> 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
>
|
|
|