AnsweredAssumed Answered

Particle Track arcpy.point failing in a loop

Question asked by ces1u17_soton_uni on Feb 18, 2019
Latest reply on Feb 20, 2019 by ces1u17_soton_uni

I'm using the particle track in python and limiting it to a specific trackingtime. For each tool run, I want the rasters input (magnitude and direction) to change to the next rasters in the lists, and the starting point of the tracking (x,y) to be derived from the last polyline point of the previous run. Attached is what I have so far but I get Error999999. It works when arcpy.point is not in a loop but fails within it. 

Any help would be very appreciated. 

 

 

for idx in range(0, len(mag)):
    print "working on index "+str(idx)
    inMagnitudeRaster= mag [idx]
    print inMagnitudeRaster
    inDirectionRaster= direction [idx]
    print inDirectionRaster
    basename= inDirectionRaster.split(".tif")[0]
    outTrackPolylineFeatures = os.path.join (OutputFolder, basename + '.shp')
    outTrackFile= os.path.join(OutputFolder, basename +'.txt')
    ParticleTrack (Raster(inDirectionRaster), os.path.join(r'C:/Time_slices/January_newrun/Magnitude2/Rectified/Stripped',inMagnitudeRaster), sourcePoint,outTrackFile, "#", trackingTime,outTrackPolylineFeatures)
    arcpy.AddField_management (outTrackPolylineFeatures, "LastX", "DOUBLE")
    arcpy.AddField_management (outTrackPolylineFeatures, "LastY", "DOUBLE")
    arcpy.CalculateField_management(outTrackPolylineFeatures, "LastX", "(!SHAPE.lastpoint.X!)", "PYTHON_9.3")
    arcpy.CalculateField_management(outTrackPolylineFeatures, "LastY", "(!SHAPE.lastpoint.Y!)", "PYTHON_9.3")
    endx, endy = [i for i in arcpy.da.SearchCursor(outTrackPolylineFeatures,['LastX','LastY'])][-1]
    sourcePoint= arcpy.Point(float(endx),float(endy),None,None)

Outcomes