Tuesday 31 October 2017

convert - Converting 4-band TIF to PNG while keeping all 4 bands?


I have a number of aerial photos containing both RGB and a near-infrared band. The images are in TIF-format, however I need to convert them to PNG without losing any of the bands. I have tried converting/exporting data in ArcMap, however this fails, unless I choose to "use renderer" in the "Export Data" dialogue, resulting in only 3 bands being saved.


I have also tried the GDAL-translate alghorhitm in QGIS, however this didn't seem to work either.



Do I have any other options?



Answer



This is a limitation of the PNG format. It only has 3 information channels (RGB), so one of your bands will be suppressed. If you really need to, you can save your NIR band as an alpha channel, but beware - you won't be able to access it easily. Neither QGIS nor ArcGIS allow allocating the alpha channel to one of its display channels. The information will still be there, but you'll only access it through image processing libraries.


Why PNG, though? This is quite a non-standard for geographic images (for starters, you don't retain georeference). If you need a small file size, consider ECW or MrSid. If you need to open it in non-GIS software, GeoTiff is a good alternative, as TIF is supported by pretty much every image software. If you really need it saved as PNG, though, what you can do is save one image with red, green and blue bands in the RGB channels, and another image with, say, red, green and NIR in the RGB channels. Then reconstruct them into one single multiband image later on. Even in this last approach, JPEG2000 is the better alternative, as you don't lose spatial information.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...