Monday 21 January 2019

arcgis desktop - How do I change geotiff "no data" color to white/transparent rather than black?


I am preparing data for inclusion into a geonetwork node, where the maps are displayed via geoserver.


The problem is that cells that have"no data" are displaying as black in the geotiff and I am would like the color to be set to white or transparent.


I am using ArcView and do not have access to either Spatial Analyst or 3D analyst.


I would prefer not to have to assign a new sld file and am presently using "Use colormap" when exporting from ArcGIS Desktop.



Answer



In concept, you need to figure out what pixel values represent cells with no data and then edit your color table to assign the RED,GREEN,BLUE (RGB) values in the color table to be 255,255,255 for that cell value.


If you don't have the appropriate license to do this in Arc, you could use the gdal_translate tool (one of the gdal/ogr commandline tools)





  1. export the color table for your tif as an XML file.
    gdal_translate -of VRT myImage.tif outColorTable.vrt




  2. open up the .vrt file in a text editor and find the entry for the value of your no data pixels. There isn't an index number for the cell values, so you have to count down to the correct entry.




  3. edit this value to be





  4. now, create a new tif based on the new color table
    gdal_translate outColorTable.vrt newCorrected.tif




(example added based on comment below)


When I run the command in item #2 above and open up the .vrt file in a text editor, I see XML contents.


Part of the file includes lines that look like this, I have snipped most of them out.


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