3

Does anyone know a good way to extract NetCDF raster values to each data point from a time enabled shapefile at the correct time?

I have tried using a python script tool and a loop that steps through time but it seems that the loop only works for the shapefile and not for the NetCDF raster - all shapefile values (from all time step intervals) end up getting assigned raster layer values just from the first time step interval. Both the raster and the shapefile are time enabled with the same time step interval and I have checked with Time Slider that the values of both change through time correctly.

Here is what I have tried:

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
1
  • There's no natural way to pass a trace index to NetCDF, you need to read arrays out and so time slices is a normal way to chunk the task - don't you need to increment through the rasterLayers per current time?
    – mdsumner
    Mar 31, 2018 at 7:25

0

Your Answer

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