Hi All -
I started using Python for a couple of weeks now, but I am stuck with the subject problem. I want to run either a CSV or a point FC providing a list of 'SourcePoints' required by the Particle Tracking tool. I've tried to set the code up in both ways, but don't know yet if it is accepted by the tool's parameters because I am getting another error regarding the outputTrack file, which is the TXT output file. The name of this output file changes with respect to the point currently run through the tool. The error I am getting reads:
Failed to execute. Parameters are not valid.
ERROR 000885: Output particle track file:
C:\GIS\Track1\1_Orig\Track1.gdb\Tracklines\xy_1.txt's does not have a file extension.
Failed to execute (ParticleTrack).
When I print 'outTrackFile', the path and filename look ok, but the extension is not recognized though.
Any help trying to solve this issue is appreciate it !
thanks
Gabriel
import arcpy, os, csv
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/GIS/Track1/1_Orig/Track1.gdb/"
# Set local variables
outWorkspace = "C:/GIS/Track1/1_Orig/Track1.gdb/Tracklines/"
inDirectionRaster = "ragw_dir2"
inMagnitudeRaster = "ragw_mag2"
stepLength = 10
trackingTime = 10000000
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
infile = open(r'C:\2_UWaterloo\10_ArcGIS\GWtoolset\LandBlocks\RA\input\SourcePts10.csv','r')
lines = []
for line in infile:
lines.append(line.split(','))
infile.close()
#print lines
#field_names = ['point_x','point_y']
#coords = arcpy.da.SearchCursor(lines, field_names)
try:
for line in lines[1:]:
x = line[0]
y = line[1]
id = line[2]
sourcePoint = arcpy.Point(x,y)
#print sourcePoint
# Output files in TXT and SHP formats for each x,y particle
#outTrackFile = os.path.join(outWorkspace,"xy_" + str(id) + ".txt")
outTrackFile = outWorkspace + "xy_" + id + ".txt"
#print outTrackFile
#outTrackPolylineFeatures = os.path.join(outWorkspace, "xy_" + str(id) + ".shp")
outTrackPolylineFeatures = outWorkspace + "xy_" + id + ".shp"
#print outTrackPolylineFeatures
# Execute ParticleTrack
ParticleTrack(inDirectionRaster, inMagnitudeRaster, sourcePoint,
outTrackFile, stepLength, trackingTime, outTrackPolylineFeatures)
except:
print arcpy.GetMessages(2)