I'm trying to make a python script tool that extracts the values from a NetCDF raster to each data point from a time enabled shapefile at the correct time. My NetCDF raster consists of monthly sea surface temperature (SST) averages and I also have a plastic debris point shapefile that has been time enabled with time step interval of one month. I have checked with Time Slider that both the raster and the shapefile values change through time correctly.
Can someone please help me figure out why I keep getting an error with this script:
mxd = arcpy.mapping.MapDocument('SST.mxd')
df = arcpy.mapping.ListDataFrames(mxd)[0]
rasterLayerName = "SST"
rasterLayer = arcpy.mapping.ListLayers(mxd, rasterLayerName, df)[0]
plasticLayerName = "Plastic"
plasticLayer = arcpy.mapping.ListLayers(mxd, plasticLayerName, df)[0]
df.time.currentTime = df.time.startTime
while df.time.currentTime <= df.time.endTime:
uniqueName = "Plastic_" + df.time.currentTime.strftime("%Y_%m")
outPointFeatures = "U:/gis/" + uniqueName
arcpy.sa.ExtractValuesToPoints(plasticLayer, rasterLayer,
outPointFeatures, "NONE", "VALUE_ONLY")
df.time.currentTime += df.time.timeStepInterval
Here is the error:
Runtime error
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 1311, in ExtractValuesToPoints
add_attributes)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper
result = wrapper(*args, **kwargs)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 1304, in wrapper
add_attributes)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 001143: Background server threw an exception.
I'm using ArcGIS Desktop 10.1 and Python 2.7 on Windows 7.