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

Home » Public Forums » archive » 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 #71714 is a reply to message #71623] Fri, 09 July 2010 21:05 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Jul 9, 12:53 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
> Hi, I'm new to IDL so this might sound very easy to some.  Sorry!
> I have 200+ .dat files in one folder, and one associated .hdr file
> that will work for all of them.
> I would like to loop through all the files and extract pixel value
> information based on an input coordinate location (lat, long) for each
> file, and then export all this information into a .txt file or
> similar.
>
> I've been trying to follow other posts that have done similar, but I
> seem to be writing this out wrong as my code isn't compiling correctly
> (I seem to have problems on lines 9 & 14, see below). I don't know
> enough about IDL rules to know the correct way to do this.
>
> If anyone could advise, I'd be so grateful!  Cheers!
>
> Name: extractdata.pro
> ;
> ; Goal: Extract pixel data based on input coordinate location for each
> file (.dat)
> ; within a specified folder location. Export this data to a .txt file.
>
> pro extractdata
> ;define path
>   filepath='X:\MERRA\HDF_Output_Lena\'
> ;open envi files within given folder
>   file_array=file_search[filepath, '*.dat', count['*.dat']= num_file]
>   for i=0, num_file-1 do begin
>
>   file=file_array[i]
>   print, num_file
>
> ;read ENVI binary file
>   read_ENVI_image (file, headerfile= filepath, '*.hdr')
> ;extract pixel information based on lat long coordinates
>   b=ENVI_CONVERT_FILE_COORDINATES [106.002, 83.0]
>   v=b
>   print, v
>
> ;open text file to write data to
> OPENU, U, 'pixel_value.txt', /get_lun, /append
> ;write data
> printf, U, v
> ;close LUN
> close, U
>
> endfor
>
> end

I think you're mixing up parentheses () and square brackets []. Use
the former for function calls and mathematical precedence, and the
latter for subscripting arrays.

(well, you can actually use parentheses to subscript arrays too, but
it's generally a better idea to use square brackets. but you
definitely can't use square brackets to call functions, as you're
doing)

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: trying to export pixel data from .dat files, based on coordinate loc
Next Topic: % POLY_FIT: Warning: Invert detected a small pivot element - help needed

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

Current Time: Fri Oct 10 14:33:32 PDT 2025

Total time taken to generate the page: 0.08298 seconds