On Monday, 29 June 2015 13:36:40 UTC-4, Priyadarsini Sivaraj wrote:
> On Monday, 29 June 2015 11:41:32 UTC-4, Priyadarsini Sivaraj wrote:
>> Hello Everyone..
>>
>> I have 15 simple ASCII files, which have to be read and the details of it are to be stored in a structure called ROI. The fields of the structure are,
>> NumROI-vector
>> Name-String
>> Color- 3 element vector
>> NumPoints-integer
>> Records-integer
>> Points- Two dimensional vector.
>>
>> I tried reading them all in a loop by using,
>>
>> FOR i=1,15 DO BEGIN
>> filename=[str,STRTRIM(i,2),ext]
>> file=[filelocation,filename]
>> Trial_ROI_Read,file
>>
>> In the procedure, I tried doing this,
>>
>> PRO Trial_ROI_Read, file
>>
>>
>> p =MAKE_ARRAY(5,198,value=1)
>> ROIs = CREATE_STRUCT('NumROI',[1],'Name','a','Color','1,1,1','NumPo ints',[1],'Records',[1],'Points',p[*,*])
>> OPENR, lun1,file, /GET_LUN
>> header = STRARR(12)
>> READF, lun1, header
>> ROIs.NumROI=STRMID(header(3),18)
>> ROIs.Name=STRMID(header(9),12)
>> ROIs.NumPoints=STRMID(header(11),13)
>> ROIs.Color=STRMID(header(10),17)
>>
>>
>> points = [id , x, y, lat, lon]
>> WHILE ~EOF(lun1) DO BEGIN
>>
>> READF, lun1, id, x, y, lat, lon
>> pt = [id,x,y,lat,lon]
>> ;print, pt
>> points = [points , pt]
>>
>> ENDWHILE
>>
>> points= REFORM(points , [ 5 , 198 ])
>>
>> But I am not able to open the file and the following error pops up:
>> OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.
>>
>> Is there any efficient way to do this..??Please do help me out..I am not well versed with IDL.
> This is my data file:
>
>
> ;2013_IEEE_GRSS_DF_Contest_Samples_TR
>
>
> ; Number of ROIs: 15
> ; File Dimension: 1905 x 349
> ; X=1 , Y=1 -> Upper-Left Corner
> ; X=1905, Y=349 -> Lower-Right Corner
>
>
> ; ROI name: grass_healthy
> ; ROI rgb value: {0, 205, 0}
> ; ROI npts: 198
> ; ID X Y Lat Lon
> 1 769 7 29.724995542787 -95.349772592660
> 2 768 7 29.724995084106 -95.349798420654
> 3 772 7 29.724996918802 -95.349695108676
> 4 771 7 29.724996460135 -95.349720936671
>
> 1 769 7 29.724995542787 -95.349772592660- This is the line where error occurs.
I have to read these values into separate variables namely,lun1, id, x, y, lat, lon. Earlier I had used a READF statement as follows:
READF, lun1, header
This is done to separate out the header and store the information present in it separately.
|