TIF files, r.tiff, pbmplus
Bart Cosyn
bcosyn at crs4.it
Thu Jan 19 04:22:12 EST 1995
Hi all,
On Wed, 18 Jan 1995, DUNN JEREMY SIMON wrote:
>
> Hello,
>
> Does anyone have any experiece with importing .TIF files into Grass4.1 ?
>
Yes I got and it works but it takes some time. In fact i was also trying
to compile r.tiff from SCS (src.contrib) but it failed because he could
not find something like a sun library. I tried it on a silicon but failed.
There are some options for doing it in an other way:
1) We have a tool here called "convert" of ImageMagick 3.4. I do not know
where it comes from but it works. There you can convert a tiff file to
one big raw file containing the 3 colorbands of a coloured image. As they
are putted in one file you need to divide the file in exactly three parts
and import the binaries in Grass. After you recompose the file to an rgb
file by using i.composite.
2) A friend of mine (Andrea Giacomelli) has another method using pbmplus
(in src.related)
and xv and it works also. I did it the same way and gives good results.
Here is the long procedure f.i you got a file called test.tif. Do this:
tifftopnm test.tif > test
ppmtorgb3 test (this creates 3 colorbands with the names test.red
.blu and .grn)
These 3 files are not really the raw files. Now you need to use xv to see
some things.
xv test.red
In xv you can do an textview of the file. You will see a header
in ascii like :
P5
2048 2048
255
It means you got a file of 2048 lines and columns with 255 colors. No
idea what P5 means. As I know the number of lines and col. and as it is
only 255 colors this image must contain 2048*2048*1=4194304 bytes. But
you will see that your file is 4194321 bytes long. So the header is 17
bytes bigger. I delete these 17 byte using the following.
dd if=test.blu of=raw.blu ibs=17 skip=1
Probably there is a better way but as sometimes tail and head have a
limit of lines and as i am not that good with line editing, this looks
the best thing to do. The idea of this dd is. I read test.blu in blocks
of 17 bytes and copy it to raw.blu but by skipping the first 17 byte i
skip the header and only retain the raw array!
Now go to grass and import your file in Grass as a binary array. Or
better run r.support after putting your file in the cell direct.!
do this for all the colorbands or put it in a script!
Than use i.composite to restore the rgb file. I you never worked with it
read also i.group!
Hope it helps but if there is another and more comfortable way to do it
please let me know!
Bart and Andrea
**************************************************************************
ir. Bart Cosyn
EC- Environment project
CRS4
Environmental modelling group
Via Nazario Sauro, 10
09123-Cagliari
Italy
Tel +/39/70/2796278
Fax +/39/70/2796216
E-mail: bcosyn at crs4.it
**************************************************************************
More information about the grass-user
mailing list