I have a 3 band raster file with RGB values (the Black Marble night time imagery from NASA). I want to get these values out and into excel so that I can plot them and hopefully see some sort of clustering for some values. I do however not know how to get the RGB values exported to a file format that works in Excel.


1 Answer 1


It is unclear what you want the output to look like, anything is possible. For example to export to one excel file with three sheets you can use arcpy, numpy and pandas python libraries. Pandas require ArcGIS version >=10.4 or you need to install pandas manually (python -m pip install pandas) Execute in python window:

import arcpy
import pandas as pd
import numpy as np

raster = r"X:\RGBraster3.tif" #Change
out_excel = r"X:\RGBexcel.xlsx" #Change

arr = arcpy.RasterToNumPyArray(raster)

with pd.ExcelWriter(out_excel) as writer:
    for colorband in range(3):
        df = pd.DataFrame(arr[colorband])
        df.to_excel(writer,sheet_name='Band_{0}'.format(colorband), header=False, index=False)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.