[FWTools] help converting format

Benoît Andrieu bea at ixsea.com
Sat Feb 13 11:37:35 EST 2010


Hi Carlos,

The GENBIN driver does not support file creation.
You have to use the EHdr driver. I think their binary format are equivalent.

    gdal_translate -of EHdr image1.tif image1.bing

It will produce one file image1.bing and one file image1.hdr

To convert all the tif files in one directory :

    FOR %g in (*.tif) DO gdal_translate -of EHdr "%~nxg"
    "converted\%~ng.bing"

Good luck.

Best regards,
Benoît Andrieu


Le 12/02/2010 22:39, Carlos Padovani a écrit :
> Please, forgot the two previous emails.
> I got it works for convert binary to tif with this command lines:
> gdal_translate -of GTiff image1 image1.tif
> gdal_translate -of GTiff -ot Byte -scale 0 10000 0 255 image1 
> image1_8bit.tif
> But actually, I need to convert images from binary format to tif 
> format. As I says in the first email.
> I sent the binary file for you to see how it looks like, and how it 
> need to be converted from tif.
> Please, could you help me for the conversion of the tif files to 
> binary files?
> I try to make it based in the command lines above, using now that 
> tif file I sent to you some emails ago and changing the transformation 
> like bellow:
> gdal_translate -of GENBIN image1.tif image1
> but I got a message error that I sent attached "error_GENBIN".
> So, how could I convert tif to binary file?
> I am sending the header file of the tif file I sent to you before with 
> the same name I used for the binary file I sent before, as well "image1".
> Thanks for your help.
> Carlos
> On Fri, Feb 12, 2010 at 7:09 PM, Carlos Padovani 
> <carlos.padovani at gmail.com <mailto:carlos.padovani at gmail.com>> wrote:
>
>     I am sending the image file with the reader file. Maybe something
>     wrong with it?
>     Carlos
>     On Fri, Feb 12, 2010 at 7:05 PM, Carlos Padovani
>     <carlos.padovani at gmail.com <mailto:carlos.padovani at gmail.com>> wrote:
>
>         Thanks!
>         I did the reader file and applied the command line bellow in
>         the FWTools Shell, but it does not works.
>         I am sending a figure with the error. Could you help me on this?
>         Carlos
>
>         On Fri, Feb 12, 2010 at 6:17 PM, Benoît Andrieu <bea at ixsea.com
>         <mailto:bea at ixsea.com>> wrote:
>
>             I managed to convert your image to tif.
>             You have to create a .hdr file next to your image in order
>             to tell gdal utilities the format of your file :
>
>                 ncols 600
>                 nrows 600
>                 cellsize 0.050401
>                 xllcorner -130.128639
>                 yllcorner 20.166799
>                 nodata_value 9999.000000
>                 nbits 16
>                 pixeltype UNSIGNEDINT
>                 byteorder lsbfirst
>
>             Then just call gdal_translate to convert your file :
>
>                 gdal_translate -of GTiff image1.bing image1.tif
>
>             This tif will be in 16bit.
>             To have it in 8bit :
>
>                 gdal_translate -of GTiff -ot Byte -scale 0 10000 0 255
>                 image1.bing image1_8bit.tif
>
>
>             I hope all your files have the same width and height.
>             Note that cellsize, xllcorner and yllcorner will be used
>             to set the geographic coordinates of your tif.
>
>
>             Le 12/02/2010 18:32, Benoît Andrieu a écrit :
>>             Do not replace yourself the n and x. It is automatically
>>             done by the command line interpretor.
>>
>>             FOR %g in (*.bing) DO gdal_translate -of JPEG "%~nxg"
>>             "%~ng.jpg"
>>
>>
>>             Le 12/02/2010 18:22, Carlos Padovani a écrit :
>>>             I am working inside the images directory to make it simple.
>>>             I tried the follow:
>>>             FOR %g in (*.bing) DO gdal_translate -of JPEG
>>>             "%~imagem1.tifg" "%~imagem1g.jpg"
>>>             But it does not work as well.
>>>
>>>             Carlos
>>>             On Fri, Feb 12, 2010 at 3:22 PM, Benoît Andrieu
>>>             <bea at ixsea.com <mailto:bea at ixsea.com>> wrote:
>>>
>>>                 Oups, sorry, I made some mistakes...
>>>
>>>                 So, first mistake, if you are using a command line
>>>                 you should only have one % and not two %%. On the
>>>                 contrary, if you are using a bat file, you should
>>>                 have two %%.
>>>                 Next, I forgot a ~ in the DO syntax it should be
>>>                 %%~nxg and %%~ng.
>>>
>>>                 So, from the command line, the correct syntax is :
>>>
>>>                     FOR %g in (C:\conversion_tif_bin\*.bing) DO
>>>                     gdal_translate -of JPEG
>>>                     "C:\conversion_tif_bin\%~nxg"
>>>                     "C:\conversion_tif_bin\%~ng.jpg"
>>>
>>>                 I haven't looked at your image at the moment...
>>>
>>>                 Regards,
>>>                 Benoît Andrieu
>>>
>>>
>>>                 Le 12/02/2010 16:18, Carlos Padovani a écrit :
>>>>                 Dear Benoît,
>>>>                 I am doing some thing wrong, but I do not know what.
>>>>                 I am sending a figure "path" with the path and
>>>>                 another figure "FWTools_Shell_error" with the error
>>>>                 message of the FWTools Shell. The message of error
>>>>                 is "%%g foi inesperado neste momento", it is in
>>>>                 Portuguese and means something like "%%g was
>>>>                 unexpected at the moment". You can see in the
>>>>                 figure "FWTools_Shell_error" how I typed the path
>>>>                 and other data necessary. I would like more help on
>>>>                 this if possible.
>>>>                 Sorry but I sent the wrong image. I am sending the
>>>>                 right one now "image1" with the data you required.
>>>>                 No. of columns: 600
>>>>                 No. of rows: 600
>>>>                 No. of bands: 1 (gray)
>>>>                 Data type: Binary 16-bit integer
>>>>                 On Fri, Feb 12, 2010 at 12:39 PM, Benoît Andrieu
>>>>                 <bea at ixsea.com <mailto:bea at ixsea.com>> wrote:
>>>>
>>>>                     Dear Carlos,
>>>>
>>>>                     Yes, you should open a FWTools shell or set the
>>>>                     FWTools path in your PATH environment variable.
>>>>                     And yes, the command line should be executed in
>>>>                     the directory where your images are but you can
>>>>                     easily customize his behaviour :
>>>>
>>>>                         mkdir __your_path__\converted
>>>>                         FOR %%g in (__your_path__\*.tif) do
>>>>                         gdal_translate -of JPEG
>>>>                         "__your_path__\%%nxg"
>>>>                         "__your_path__\converted\%%ng.jpg"
>>>>
>>>>                     The first line will create a new folder in your
>>>>                     folder.
>>>>
>>>>                     FOR %%g in (__your_path__*.tif)    ===> This
>>>>                     will select all the files in your directory and
>>>>                     iterate with the %%g variable
>>>>                     "%%nxg"                            ===> n =
>>>>                     name of the file without its extension, x =
>>>>                     extension of the file, g = the name of the variable
>>>>                     "%%ng.jpg"                         ===> This
>>>>                     will change the extension of the file
>>>>
>>>>                     Regarding the binary format, could you tell me
>>>>                     more about the file you sent ?
>>>>                     I would need its width, height, number of bands
>>>>                     (gray, RGB, ARGB ?) and the data type of each
>>>>                     pixel (Byte, Int16, Float32 ?).
>>>>                     Thanks.
>>>>                     I would use the GenBin format too but
>>>>                     unfortunately, GDAL is only able to read them...
>>>>
>>>>                     *_To the list :_*
>>>>                     You can find the file sent by Carlos at this
>>>>                     address
>>>>                     http://benoit.andrieu.free.fr/00046agua.zip
>>>>
>>>>                     Best regards,
>>>>                     Benoît Andrieu
>>>>
>>>>
>>>>
>>>>                     Le 12/02/2010 13:06, Carlos Padovani a écrit :
>>>>>                     Dear Benoît,
>>>>>                     thanks very much for your fast response.
>>>>>                     I am not familiar with command line
>>>>>                     procedures, so could you explain in more
>>>>>                     details what should I do for to convert the
>>>>>                     tif images to other format?
>>>>>                     I will use this command line in the FWTools
>>>>>                     Shell? I need to wrote this command line in a
>>>>>                     directory where the images are?
>>>>>                     I took a look in the
>>>>>                     http://www.gdal.org/formats_list.html and I
>>>>>                     guess that the binary files I need to convert
>>>>>                     from tif are the Generic Binary (GenBin).
>>>>>                     I am sending an image file for you to take a
>>>>>                     look if you agree and maybe help me to
>>>>>                     identify if it is the same Generic Binary of
>>>>>                     gdal format list.
>>>>>                     Thanks once more.
>>>>>                     Carlos
>>>>>                     On Fri, Feb 12, 2010 at 10:04 AM, Benoît
>>>>>                     Andrieu <bea at ixsea.com <mailto:bea at ixsea.com>>
>>>>>                     wrote:
>>>>>
>>>>>                         I don't know about binary formats but you
>>>>>                         should find what you want here :
>>>>>                         http://www.gdal.org/formats_list.html
>>>>>
>>>>>
>>>>>                         You can use a bat file to convert all
>>>>>                         files from a folder :
>>>>>
>>>>>                             mkdir converted
>>>>>                             FOR %%g in (*.tif) do gdal_translate
>>>>>                             -of JPEG "%%nxg" "converted\%%ng.jpg"
>>>>>
>>>>>
>>>>>                         Regards,
>>>>>                         Benoît Andrieu
>>>>>
>>>>>
>>>>>
>>>>>                         Le 12/02/2010 11:00, Carlos Padovani a
>>>>>                         écrit :
>>>>>>                         Dear users of FWTools,
>>>>>>                         I need to convert a lot of images form
>>>>>>                         TIFF format to binary format.
>>>>>>                         It is possible to do it in FWTools, but I
>>>>>>                         do not know which is the format available
>>>>>>                         in the software that correspond to binary
>>>>>>                         format. Another thing is that in FWTools
>>>>>>                         I can convert the images one by one, and
>>>>>>                         as I have a lot of images to convert, I
>>>>>>                         would like a way to convert a lot of
>>>>>>                         images at once. I use Windows WP as
>>>>>>                         operacional system.
>>>>>>                         Could someone help me?
>>>>>>                         Thanks in advance.
>>>>>>                         Carlos
>>>>>>
>>>>>>
>>>>>>                         _______________________________________________
>>>>>>                         FWTools mailing list
>>>>>>                         FWTools at lists.maptools.org  <mailto:FWTools at lists.maptools.org>
>>>>>>                         http://lists.maptools.org/mailman/listinfo/fwtools
>>>>>>                         http://fwtools.maptools.org/
>>>>>>                            
>>>>>
>>>>>                         _______________________________________________
>>>>>                         FWTools mailing list
>>>>>                         FWTools at lists.maptools.org
>>>>>                         <mailto:FWTools at lists.maptools.org>
>>>>>                         http://lists.maptools.org/mailman/listinfo/fwtools
>>>>>                         http://fwtools.maptools.org/
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>                     -- 
>>>>>                     Carlos Padovani
>>>>>                     Pesquisador
>>>>>                     Embrapa Pantanal
>>>>>                     www.cpap.embrapa.br <http://www.cpap.embrapa.br/>
>>>>>                     SKYPE: carlos.padovani
>>>>>                     MSN:crpadovani at hotmail.com
>>>>>                     <mailto:MSN%3Acrpadovani at hotmail.com>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>                 -- 
>>>>                 Carlos Padovani
>>>>                 Pesquisador
>>>>                 Embrapa Pantanal
>>>>                 www.cpap.embrapa.br <http://www.cpap.embrapa.br/>
>>>>                 SKYPE: carlos.padovani
>>>>                 MSN:crpadovani at hotmail.com
>>>>                 <mailto:MSN%3Acrpadovani at hotmail.com>
>>>>
>>>>
>>>
>>>
>>>
>>>             -- 
>>>             Carlos Padovani
>>>             Pesquisador
>>>             Embrapa Pantanal
>>>             www.cpap.embrapa.br <http://www.cpap.embrapa.br/>
>>>             SKYPE: carlos.padovani
>>>             MSN:crpadovani at hotmail.com
>>>             <mailto:MSN%3Acrpadovani at hotmail.com>
>>>
>>>
>
>
>
>         -- 
>         Carlos Padovani
>         Pesquisador
>         Embrapa Pantanal
>         www.cpap.embrapa.br <http://www.cpap.embrapa.br/>
>         SKYPE: carlos.padovani
>         MSN:crpadovani at hotmail.com <mailto:MSN%3Acrpadovani at hotmail.com>
>
>
>
>
>
>     -- 
>     Carlos Padovani
>     Pesquisador
>     Embrapa Pantanal
>     www.cpap.embrapa.br <http://www.cpap.embrapa.br/>
>     SKYPE: carlos.padovani
>     MSN:crpadovani at hotmail.com <mailto:MSN%3Acrpadovani at hotmail.com>
>
>
>
>
>
> -- 
> Carlos Padovani
> Pesquisador
> Embrapa Pantanal
> www.cpap.embrapa.br <http://www.cpap.embrapa.br>
> SKYPE: carlos.padovani
> MSN:crpadovani at hotmail.com <mailto:MSN%3Acrpadovani at hotmail.com>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20100213/d8a5e4f6/attachment-0001.htm 


More information about the FWTools mailing list