Jump to content

 
Photo

gdal_merge - strange colours output

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Jan Helebrant

Jan Helebrant

    Contributor

  • Validated Member
  • PipPip
  • 24 posts
  • Gender:Male
  • Interests:GIS, open-source, graphics (both 2D and 3D), multimedia, taking photos
  • Czech Republic

Hi,
today I needed to merge some of the map tiles described here:
http://www.cartotalk...?showtopic=4873

but most of my programs failed. SAGA GIS is able to do it, but in this case it needs to manuallly import every single tile and finally had problems to export such a big file.

When using SAGA gdal export, then the colors were strange - a lot of purple instad of green etc. I found an advice how to do it via cmd with gdal_merge and generated filelist using:

Microsoft Windows XP [Verze 5.1.2600]

(C) Copyright 1985-2001 Microsoft Corp.

C:\WINDOWS>cd C:\D\EDU_ETE_mapy_zony\ETE_map_tiles\BW

C:\D\EDU_ETE_mapy_zony\ETE_map_tiles\BW>gdal_merge -o merged.tif --optfile filelist.txt

but the output colors were also bad. I tried to convert all images with IrfanView to BW only images (not grayscale), but then is something wrong as the gdal output is black only.

there is probably one problem - when merging, gdal says:
Warning 1: TIFFReadDirectory:Unknown field with tag 33918 (0x847e) encountered

Warning 1: TIFFFetchNormalTag:ASCII value for tag "GeoASCIIParams" does not end

in null byte

SAGA reported something similars but I was able to get normal colors using "Force true colors" option, so I do not know how important is it.

does anybody have an idea to solve this? The correct color map would be nice but for most common use the 2bit (B-W) is enough (map is often used as background layer).

thanks

#2
Nick H

Nick H

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 307 posts
  • Gender:Male
  • Location:Caversham, Reading, England.
  • United Kingdom

Hi Jan,

I don't know if this is anything to do with your problem, but it appears that your TIFFs are GEOTIFFs. However, they also have world files. It might be an idea to rename the world files to something like 'filename.OLD' and trying gdal_merge again.

Regards, N.
Caversham, Reading, England.

#3
Jan Helebrant

Jan Helebrant

    Contributor

  • Validated Member
  • PipPip
  • 24 posts
  • Gender:Male
  • Interests:GIS, open-source, graphics (both 2D and 3D), multimedia, taking photos
  • Czech Republic

It might be an idea to rename the world files to something like 'filename.OLD' and trying gdal_merge again.


OK,
I moved the world files to other folder and tried merge again. However this did not have any effect and the result picture looked similar to B-W negative. I tried to modify the tif in IrfanView to get better image (used "Negative" function and highlighted the main lines etc. using Gamma correction and resaved the tif). But when using import raster via Gdal, then I get the same pictures in both cases - those negative pictures.

I will try to merge less files in SAGA, where I am able to get normal colors and save it as tif/jpeg/png with world file. With this huge map, SAGA crashes during file export (only export via Gdal works, but with mentioned problems). So I will rather use maybe 4 tiles instead one.

#4
Nick H

Nick H

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 307 posts
  • Gender:Male
  • Location:Caversham, Reading, England.
  • United Kingdom

The only other suggestion I have is to load the TIFFs into Irfanview and save them as JPGs (don't do any resampling or resizing). Then make a copies of the TFW world files and change the extension to 'jpw' (for example, tilename.jpw). Then try gdal_merge on the JPGs.

Added later: when you convert from TIFF to JPG it might also be a good idea to check that the colour-depth is the same for each image. But whether this has anything to do with the price of fish, I don't know :).

It might also be worth trying gdal_merge in this way (though I can't see why this should make any difference):

gdal_merge -o merged.tif tile1.jpg tile2.jpg tile3.jpg tile4.jpg

Just a couple of thoughts.

Regards, N.
Caversham, Reading, England.

#5
Jan Helebrant

Jan Helebrant

    Contributor

  • Validated Member
  • PipPip
  • 24 posts
  • Gender:Male
  • Interests:GIS, open-source, graphics (both 2D and 3D), multimedia, taking photos
  • Czech Republic

Thanks,
the trick with jpeg files worked and now I have 11820 x 9456 319.85 MB file but in correct colors. Also works correctly with those B-W images ("only" 100MB output file). So I will use the method again and will create more smaller files, as this is too huge and causes some loading problems.

The merge syntax
gdal_merge -o merged.tif --optfile filelist.txt
was used because I have 80 these tiles, and I am able to create folder filelist using cmd so it is easier than manual writing (I found it somewhere via Google).

regards,
Jan

#6
Nick H

Nick H

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 307 posts
  • Gender:Male
  • Location:Caversham, Reading, England.
  • United Kingdom

...the trick with jpeg files worked and now I have 11820 x 9456 319.85 MB file but in correct colors...


It's good that you've managed to get round the problem, but I wonder what caused the problem in the first place. I remembered that I have one of your TIFFs so I dumped the metadata from it, see below. Perhaps the problem was with Packbits compression, heaven knows.

Driver: GTiff/GeoTIFF

Files: C:\Temp\f332200w175.tif

Size is 1182, 1182

Coordinate System is:

PROJCS["WGS 84 / UTM zone 33N",

	GEOGCS["WGS 84",

		DATUM["WGS_1984",

			SPHEROID["WGS 84",6378137,298.2572235630016,

				AUTHORITY["EPSG","7030"]],

			AUTHORITY["EPSG","6326"]],

		PRIMEM["Greenwich",0],

		UNIT["degree",0.0174532925199433],

		AUTHORITY["EPSG","4326"]],

	PROJECTION["Transverse_Mercator"],

	PARAMETER["latitude_of_origin",0],

	PARAMETER["central_meridian",15],

	PARAMETER["scale_factor",0.9996],

	PARAMETER["false_easting",500000],

	PARAMETER["false_northing",0],

	UNIT["metre",1,

		AUTHORITY["EPSG","9001"]],

	AUTHORITY["EPSG","32633"]]

Origin = (437498.942470000010000,5502501.057529999900000)

Pixel Size = (2.115060000000000,-2.115060000000000)

Metadata:

  AREA_OR_POINT=Area

  TIFFTAG_SOFTWARE=ThumbsPlus image management system

  TIFFTAG_XRESOLUTION=300

  TIFFTAG_YRESOLUTION=300

  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)

Image Structure Metadata:

  COMPRESSION=PACKBITS

  INTERLEAVE=BAND

Corner Coordinates:

Upper Left  (  437498.942, 5502501.058) ( 14d 8'1.59"E, 49d40'18.48"N)

Lower Left  (  437498.942, 5500001.057) ( 14d 8'3.02"E, 49d38'57.53"N)

Upper Right (  439998.943, 5502501.058) ( 14d10'6.31"E, 49d40'19.39"N)

Lower Right (  439998.943, 5500001.057) ( 14d10'7.69"E, 49d38'58.45"N)

Center	  (  438748.943, 5501251.057) ( 14d 9'4.65"E, 49d39'38.47"N)

Band 1 Block=1182x56 Type=Byte, ColorInterp=Palette

  Color Table (RGB with 256 entries)

	0: 0,0,0,255

	1: 0,0,0,255 

===========Remainder Cut==========
Regards, N.
Caversham, Reading, England.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->