Monday 8 June 2015

qgis - Flattening JP2 files to single band (i.e. averaging bands)?


I have created thousands of png tiles using ArcGIS and have merged groups of them into large jp2 files for serving via GeoServer. I need to flatten these to a single band so that I can apply a colour map to achieve transparency.


Merge single band and multi band color images is similar but the suggested tool "Composite Bands tool in arctoolbox" only merges single band to 3 band. I need the reverse!



This is based on the following question Getting a constant background color for transparency


I have arcgis 10.1, qgis/gdal, erdas imagine and global mapper.



Answer





QGIS: Use the Raster Calculator to average the three bands (with a "+1" so you don't get a divide by 0 error); you can do more advanced averaging if you want of course:


(raster_name@1 + raster_name@2 + raster_name@3 + 1) / 3


This results in a single band output. It supports all output formats that QGIS does, I don't see JP2 on the list, but I didn't look that hard.




ArcGIS: Same premise as QGIS; you'll need the Spatial Analyst Extension to get the Raster Calculator. Looking at it though, ArcGIS doesn't make it as easy to get access to bands via the calculator (its poorly documented, but see here: http://forums.arcgis.com/threads/35761-ArcGIS-10-selecting-attributes-from-multiple-bands )




In ArcGIS 10 Raster Catalog, use full catalog path names instead of layer names in the expression.


(("C:\Test\KALI-1415.jpg\Band_1") <= 50) & (("C:\Test\KALI-1415.jpg\Band_2") >= 120) & (("C:\Test\KALI-1415.jpg\Band_3") <= 173)


*KALI-1415.jpg is my example image.





FME: You didn't ask for this one, but as its available under a free evaluation license. Easy to do, can also do all of the mosaicing and stuff but I guess you've done that. Its either RasterInterpretationCoercer or RasterBandInterpretationCoercer.


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...