Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Re: Rescaling byte (0-200) ndvi to -1 to 1 values
On 07/19/12 14:18, Narnia wrote: > I'm using the eMODIS 10-day product from the USGS with this description: "MODIS NDVI data are stretched (mapped) > linearly (to byte values) as follows: [-1.0, 1.0] -> [0, 200] Invalid Values: 201 - 255 > > NDVI = (value ï¿½ 100) / 100; example: [ (150 ï¿½ 100) / 100 = 0.5 NDVI ]" > > I am trying thus to scale the data in ENVI just using Band Math [expression:((b1-100)/100)] and all the values I get > are 0 across my entire image. Any thoughts as to why? IDL> value = 150 IDL> help, (value - 100) / 100 <Expression> LONG = 0 IDL> value = 150.0 IDL> help, (value - 100) / 100 <Expression> FLOAT = 0.500000 > > Secondly, I need to do this for over 400 images; can someone suggest a quick script that can read and scale this data > in IDL? I tried 'ScaledImage' but i keep getting errors as well... I would write one myself. Mostly since the scaling is just a one-line operation. At least you know you're getting the correct (or wrong) answer that way. :o) cheers, paulv
Thanks a lot, Paul, that makes sense of course but (I'm a real beginner with IDL), I'm still not sure how I would implement that as far as calling in the images and declaring that to run and scale all the images in my folder! :( On Thursday, July 19, 2012 9:18:39 PM UTC+3, Narnia wrote: > I'm using the eMODIS 10-day product from the USGS with this description: "MODIS NDVI data are stretched (mapped) linearly (to byte values) as follows: > [-1.0, 1.0] -> [0, 200] > Invalid Values: 201 - 255 > > NDVI = (value – 100) / 100; example: [ (150 – 100) / 100 = 0.5 NDVI ]" > > I am trying thus to scale the data in ENVI just using Band Math [expression:((b1-100)/100)] and all the values I get are 0 across my entire image. Any thoughts as to why? > > Secondly, I need to do this for over 400 images; can someone suggest a quick script that can read and scale this data in IDL? I tried 'ScaledImage' but i keep getting errors as well... > > Thank you so much!
Hello, On 07/19/12 15:19, Narnia wrote: > Thanks a lot, Paul, that makes sense of course but (I'm a real beginner with IDL), I'm still not sure how I would > implement that as far as calling in the images and declaring that to run and scale all the images in my folder! :( Well, let's assume you already have a function that reads the image data (I can't help with that one). Let's call it "read_image" and assume it looks something like: FUNCTION Read_Image, Filename ...open file... ...read image data... RETURN, image_data END Your scaling function could look like FUNCTION Scale_Image, Input_Image output_image = FLOAT(Input_Image) output_image = (output_image - 100.0) / 100.0 RETURN, output_image END Then you can loop over your filenames on the command line IDL> files = FILE_SEARCH("path/to/data/emodis.filename.*") IDL> FOR n = 0, N_ELEMENTS(files) DO BEGIN & scaled_image = Scale_Image(Read_Image(files[n])) & ...display... & ENDFOR ? cheers, paulv
You're my hero, thank you so much! It's perfect. On Thursday, July 19, 2012 9:18:39 PM UTC+3, Narnia wrote: > I'm using the eMODIS 10-day product from the USGS with this description: "MODIS NDVI data are stretched (mapped) linearly (to byte values) as follows: > [-1.0, 1.0] -> [0, 200] > Invalid Values: 201 - 255 > > NDVI = (value – 100) / 100; example: [ (150 – 100) / 100 = 0.5 NDVI ]" > > I am trying thus to scale the data in ENVI just using Band Math [expression:((b1-100)/100)] and all the values I get are 0 across my entire image. Any thoughts as to why? > > Secondly, I need to do this for over 400 images; can someone suggest a quick script that can read and scale this data in IDL? I tried 'ScaledImage' but i keep getting errors as well... > > Thank you so much!
Narnia writes: > You're my hero, thank you so much! It's perfect. Geez, I might start answering questions again! Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Well, Dr. Coyote, you're the untouchable hero, I've drooling over your website quite a bit :P On Friday, July 20, 2012 4:07:51 PM UTC+3, David Fanning wrote: > Narnia writes: > > > You're my hero, thank you so much! It's perfect. > > Geez, I might start answering questions again! > > Cheers, > > David > > > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ > Sepore ma de ni thui. ("Perhaps thou speakest truth.")
That would be a good idea, Dr. Coyote; I've been 'drooling' over your website quite a bit :) On Friday, July 20, 2012 4:07:51 PM UTC+3, David Fanning wrote: > Narnia writes: > > > You're my hero, thank you so much! It's perfect. > > Geez, I might start answering questions again! > > Cheers, > > David > > > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ > Sepore ma de ni thui. ("Perhaps thou speakest truth.")
On Thursday, July 19, 2012 11:13:32 PM UTC+3, Paul van Delst wrote: > Hello, > > > > On 07/19/12 15:19, Narnia wrote: > >> Thanks a lot, Paul, that makes sense of course but (I'm a real beginner with IDL), I'm still not sure how I would > >> implement that as far as calling in the images and declaring that to run and scale all the images in my folder! :( > > > > Well, let's assume you already have a function that reads the image data (I can't help with that one). Let's call it > > "read_image" and assume it looks something like: > > > > FUNCTION Read_Image, Filename > > ...open file... > > ...read image data... > > RETURN, image_data > > END > > > > Your scaling function could look like > > > > FUNCTION Scale_Image, Input_Image > > output_image = FLOAT(Input_Image) > > output_image = (output_image - 100.0) / 100.0 > > RETURN, output_image > > END > > > > Then you can loop over your filenames on the command line > > > > IDL> files = FILE_SEARCH("path/to/data/emodis.filename.*") > > IDL> FOR n = 0, N_ELEMENTS(files) DO BEGIN & scaled_image = Scale_Image(Read_Image(files[n])) & ...display... & ENDFOR > > > > ? > > > > cheers, > > > > paulv Hi Paul, I have seen your suggestion, but I don't work in IDL. Can you tell me this process in ArcGIS? Thank you in advance for your kind support. KS