Re: read/writing tiff files [message #35629] |
Sat, 28 June 2003 14:17  |
alex_panton
Messages: 5 Registered: June 2003
|
Junior Member |
|
|
thanks for all your advice, literally straight after i posted though i
managed to get it to work.. typical!
cheers
alex
David Fanning <david@dfanning.com> wrote in message news:<MPG.19675378bd56891a989693@news.frii.com>...
> Alexandra Panton writes:
>
>> my code so far...
>>
>> stuff = ('f:\ftp_web_root\Recent\hawaii\GOES_9\all')
>> store = ('d:\goes\hawaii')
>>
>> cd, stuff
>> ...
>> outname=input+'bt' ;output file name;
>> cd, store
>> openw,1, outname ;opens a file with outname filename;
>> write_tiff,input ;writes a tiff file of input array
>> close,1
>> free_lun,1
>> x=x+1 ;loops round to next image;
>> endwhile
>> end
>>
>> When i run this it stops at the openw command with a type conversion
>> error: Unable to convert given STRING to Byte.
>
> When you get the error message, you should read it carefully
> to see what line the error occurs on. They you go to that
> line in the program and stare at it for a period of time that
> is inversely proportional to the time you have been working
> with IDL (or sometimes, in rare cases, or if you are under
> a tight deadline, a hell of a lot longer).
>
> In your case, you will probably be looking at this line:
>
> outname=input+'bt' ;output file name;
>
> What's wrong with it? Hard to say on the surface. The
> code looks good, no quotes missing or anything. Everything's
> spelled OK. But what are you trying to do? Create an output
> filename, right? A string. Are your arguments strings? Well,
> don't know. Let's see.
>
> IDL> Help, input
> INPUT BYTE = Array[360, 360]
>
> A byte array!? That's not what I thought input was!
>
> Uh, huh. And that's the problem. In fact, now the
> error message makes some sense. You are trying to
> add apples and oranges and the computer is telling you
> it doesn't know how to do that.
>
> You probably meant something like this:
>
> outname = files[x] + 'bl'
>
> Or, perhaps something more sophisticated, like this:
>
> name = StrSplit(files[x], '.', /Extract)
> outname = name[0] + 'bl.' + name[1]
> Print, files[x], outname
> picture123.tif picture123bl.tif
>
> OK, fix that, then recompile and run it again.
>
> What!? Another error! Oh, oh. This is too much like
> work. No wonder I don't write programs for a living.
> This kind of stuff drives me crazy!!!
>
> What the hell is the matter with that WRITE_TIFF line!?
> I copied that from Mike's program and *his* works!
>
> Oh, wait a minute. Maybe I copied that from his
> program that didn't work. :-(
>
> In any case, I would turn this (which surely won't work):
>
> cd, store
> openw,1, outname ;opens a file with outname filename;
> write_tiff,input ;writes a tiff file of input array
> close,1
> free_lun,1
>
> Into this:
>
> cd, store
> write_tiff, outname, input
>
> *Then* we might get somewhere! :-)
>
> Cheers,
>
> David
|
|
|