comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: trying to export pixel data from .dat files, based on coordinate loc
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: trying to export pixel data from .dat files, based on coordinate loc [message #71695 is a reply to message #71616] Mon, 12 July 2010 14:51 Go to previous messageGo to previous message
Maxwell Peck is currently offline  Maxwell Peck
Messages: 61
Registered: February 2010
Member
On Jul 13, 7:39 am, Maxwell Peck <maxjp...@gmail.com> wrote:
> On Jul 13, 7:29 am, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>
>
>> On Jul 12, 3:12 pm, Maxwell Peck <maxjp...@gmail.com> wrote:
>
>>> On Jul 13, 6:37 am, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>>>> Thanks to all who gave great advice. I almost have this up and
>>>> running, but have a few more questions.
>
>>>> 1. At the moment, I have tested this code based on two files that each
>>>> have their own .hdr. For the real thing, I want to create only
>>>> one .hdr that can be used for all (200+) files since they have the
>>>> same dims, data type, etc. How can I modify this code to look for that
>>>> one .hdr file and use information from that file when looping through
>>>> each file in the folder?
>
>>>> 2. The ENVI Available Bands GUI pops up when I run this.  Is this
>>>> supposed to happen? I read that envi_open_file was non-interactive in
>>>> idl (with batch mode).
>
>>>> 3. The way the code currently reads, it will output twice when I run
>>>> it but only giving me pixel data from the first file read under
>>>> 'file'.  I think that I need to write a loop to specify to read from
>>>> the 'file' list one at a time, go through the code, close that file,
>>>> and then start with the next.  I'm not sure, though, how to write
>>>> this, and would appreciate advice.
>
>>>> 4. I did notice that I'm not getting back the correct sample/line
>>>> pixel file locations from my input map locations (x,y). They seem to
>>>> be one pixel off. Has anyone else had this happen?
>
>>>> The code is shown below. Thanks again!
>
>>>>  Goal: Extract pixel data based on input coordinate location for each
>>>> file (ENVI binary)
>>>> ; within a specified folder location. Export this data to a .csv file.
>
>>>> pro extractdata4
>
>>>> ;define path
>>>>  cd, 'X:\MERRA\HDF_Output_Lena\test\'
>
>>>> ;open envi files within given folder
>>>>   file_array=file_search('*.dat', count=num_file)
>
>>>> for i=0, num_file-1 do begin
>>>>   file=file_array
>>>>   endfor
>>>> print, num_file
>>>>   print, file
>
>>>> ;read ENVI binary files
>
>>>>   envi_open_file , file, r_fid=fid
>
>>>> ;convert x,y map coordinates to corresponding pixel coordinates. note
>>>> that xmap and ymap can be single values or arrays if
>>>> ;needed to extract info for multiple pixels.
>>>>   XMap=[109.55551335]
>>>>   YMap=[79.25]
>
>>>>   ENVI_CONVERT_FILE_COORDINATES, fid,XF, YF, XMap, YMap
>
>>>> XF_out=Round(XF)
>>>> YF_out=Round(YF)
>>>> print, 'x pix' ,XF_out
>>>> print, 'y pix', YF_out
>
>>>> ;specify the data dims for the pixels who's info you want to extract.
>>>> pos specifies which band(s) you want to extract from.
>>>> ;for example, if I have 4 bands and I only want to extract from bands
>>>> 1 and 4, pos would be [0,3]. Then extract for these pixels/bands.
>>>>   dims=[-1, XF_out, XF_out, YF_out, YF_out]
>>>>   pos=[0]
>>>>   pixdata = ENVI_GET_DATA(fid=fid, dims=dims, pos=pos)
>
>>>>   print, pixdata
>>>> ;open text file to write data to
>>>> OPENU, U, 'pixel_value.csv', /get_lun, /append
>>>> ;write data
>>>> printf, U, pixdata
>>>> ;close LUN
>>>> close, U
>
>>>> end
>
>>> 1. It can be done just using IDL to read in the images but it will
>>> probably be easier for you just to duplicate the header file and keep
>>> them in ENVI format. (Unless you wanted to completely rewrite the
>>> program)
>
>>> 2. You probably want ,/NO_REALISE in your envi_open_file.
>
>>> 3. Yes, use ENVI_FILE_MNG to close the file each time after the map
>>> conversion.
>
>>> 4. Is it one pixel off or half a pixel off ?
>
>>> Max- Hide quoted text -
>
>>> - Show quoted text -
>
>> Thanks Max.
>
>> I just checked and it is one pixel off, not 0.5.
>
> Ok, im assuming you're using ENVI to check. Envi starts at 1,1 in the
> top left whereas the conversion i think uses 0,0 . I don't have envi
> here to check at the moment so I'd take a look yourself.

(I should add this is defined by the xstart and ystart in the ENVI
header.. Whether yours will change from 1,1 i don't know.)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: SAVE compress and Gzip
Next Topic: trying to export pixel data from .dat files, based on coordinate loc

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:57:58 PDT 2025

Total time taken to generate the page: 0.00435 seconds