-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetCDF2Raster_L8.py
34 lines (30 loc) · 1.49 KB
/
netCDF2Raster_L8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import shutil
import os
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
arcpy.env.workspace = "Z:/LaRC_ChesapeakeBayWaterResourcesII/Data/Landsat8_AllScenes/P15R33" # change to the path where all files with .nc files are
overwriteOutput = True
#Make NetCDF Raster Layer Input Variables
variableList = ["RRS_443", "RRS_483", "RRS_561", "RRS_655", "RRS_865", "RRS_1609", "RRS_2201", "T_DOGLIOTTI", "T_DOGLIOTTI_RED", "T_DOGLIOTTI_NIR", "T_GARABA_645_LIN", "T_NECHAD_645"]
XDimension = "x"
YDimension = "y"
bandDimmension = ""
dimensionValues = ""
valueSelectionMethod = ""
i = 1
SatelliteSceneFolder = arcpy.ListWorkspaces()
for folder in SatelliteSceneFolder:
print folder
arcpy.env.workspace = folder
ncFiles = arcpy.ListFiles("*.nc")
for ncFile in ncFiles:
netCDFInput = os.path.abspath(folder) + '/' + ncFile
netCDFInput_fixed = netCDFInput.replace('\\','/')
for variable in variableList:
print variable
tempOutputRaster = "TemporaryRaster" + str(i)
i = i + 1
copyRasterOutput = os.path.abspath(folder) + '/' + ncFile.split(".")[0] + "_" + str(variable) + "_acolite_nirAtmosCorr" + ".tif"
copyRasterOutput_fixed = copyRasterOutput.replace('\\','/')
arcpy.MakeNetCDFRasterLayer_md(netCDFInput_fixed, variable, XDimension, YDimension, tempOutputRaster, bandDimmension, dimensionValues, valueSelectionMethod)
arcpy.CopyRaster_management(tempOutputRaster, copyRasterOutput_fixed, "", "", "", "NONE", "NONE", "", "NONE", "NONE", "TIFF", "NONE")