Hi All,
I have one NetCDF file, that contain monthly value for the different year (1910 - 2014). I want to extract few years data (e.g 2000 - 2014), date range reading from a csv file and save it as a raster map as the name format of year-month-date. I am working on below script but I am getting error
Below i have attached the csv file which i am using for date range purpose.
Any help would be greatly appreciated! Thanks
The image showing the format of Year-month-date
Error massage
Traceback (most recent call last):
File "<module4>", line 18, in <module>
ValueError: 'Date' is not in list
Here what i have so far
import os, sys
import arcpy
arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
netCDF = "C:\\Users\\Downloads\\SPIE"
rainfall = "C:\\Users\\Downloads\\SPIE\\New folder"
arcpy.env.workspace = netCDF
eveDate = open ("C:\\Users\\Downloads\\SPIE\\Name1.csv")
headerLine = eveDate.readline()
valueList = headerLine.split(",")
dateValueIndex = valueList.index("Date")
eventList = []
for line in eveDate.readlines():
segmenLine = line.split(",")
variable = "spei"
x_dimension = "lon"
y_dimension = "lat"
band_dimension = ""
for year in range(2010):
nc_name = 'spei.%d.nc' % (year,)
valueSelectionMethod = "BY_VALUE"
outFile = "Pre"
arcpy.MakeNetCDFRasterLayer_md("spei.nc", variable, x_dimension, y_dimension, outFile, band_dimension, segmenLine[dateValueIndex], valueSelectionMethod)
print "layer done"
arcpy.CopyRaster_management(outFile, rainfall + segmenLine[dateValueIndex] + ".tif" , "", "", "", "NONE", "NONE", "")
print "raster done"