Created
November 24, 2013 04:35
-
-
Save hallahan/7623367 to your computer and use it in GitHub Desktop.
Sums a bunch of binary masks together so you can have classification groups that show how many images in our set are cloudless.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import arcpy | |
from arcpy.sa import * | |
arcpy.CheckOutExtension('Spatial') | |
arcpy.env.overwriteOutput = True | |
cwd = os.getcwd() | |
inputPath = cwd + "\\intermediate\\" | |
outputPath = cwd + "\\output\\" | |
inputFiles = os.listdir(inputPath) | |
sumRaster = None | |
for img in inputFiles: | |
if img.split('.')[-1] == 'TIF': | |
imgPath = inputPath + img | |
if sumRaster is None: | |
print('Starting with ' + img + ' in the summed raster...') | |
sumRaster = Raster(imgPath) | |
else: | |
print('Adding ' + img + ' to the summed raster...') | |
sumRaster += Raster(imgPath) | |
outputFileName = img.split('_')[0] + '_BINSUM.TIF' | |
print("Saving final sum of binary masks as " + outputFileName) | |
sumRaster.save(outputPath + outputFileName) | |
print("Success!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment