I have no idea what the issue is here, the scripting tool works fine when I run it through desktop. However, I continue to have problems publishing it as a service. The following is the error (00178) that I keep receiving:
import arcpy, csv, datetime output = arcpy.GetParameterAsText(0) DATA = r'C:\!PROD_Connections_SDE\PROD@ABC.sde\ABC.PROD.S2_testbuild\ABC.PROD.ABC_testline' #table = arcpy.MakeFeatureLayer_management(DATA,"data") # Map of UTM Zone WKIDs, modify as needed utmZones = {10: 32610, 11: 32611, 12: 32612, 13: 32613} pLength = 0.0 hLength = 0.0 def getUTMZone(geometry): #http://gis.stackexchange.com/questions/13291/computing-utm-zone-from-lat-long-point from math import floor geo = geometry.projectAs(arcpy.SpatialReference(4326)) lon = geo.trueCentroid.X return int(floor((lon + 180)/6) + 1) with arcpy.da.SearchCursor(DATA,["SHAPE@","Activity"]) as cur: for row in cur: utmZone = getUTMZone(row[0]) sr = arcpy.SpatialReference(utmZones[utmZone]) # Project line to correct UTM zone and add its length to the correct sum geom = row[0].projectAs(sr) if row[1] == "HDD": hLength += geom.length else: pLength += geom.length # Write data to CSV with open(output,'wb') as outFile: date = datetime.datetime.today() headers = ("Date","P Total Length (m)","H Total Length (m)") record = (str(date),str(plength),str(hlength)) writer = csv.writer(outFile) writer.writerow(headers) writer.writerow(record)
أكثر...
import arcpy, csv, datetime output = arcpy.GetParameterAsText(0) DATA = r'C:\!PROD_Connections_SDE\PROD@ABC.sde\ABC.PROD.S2_testbuild\ABC.PROD.ABC_testline' #table = arcpy.MakeFeatureLayer_management(DATA,"data") # Map of UTM Zone WKIDs, modify as needed utmZones = {10: 32610, 11: 32611, 12: 32612, 13: 32613} pLength = 0.0 hLength = 0.0 def getUTMZone(geometry): #http://gis.stackexchange.com/questions/13291/computing-utm-zone-from-lat-long-point from math import floor geo = geometry.projectAs(arcpy.SpatialReference(4326)) lon = geo.trueCentroid.X return int(floor((lon + 180)/6) + 1) with arcpy.da.SearchCursor(DATA,["SHAPE@","Activity"]) as cur: for row in cur: utmZone = getUTMZone(row[0]) sr = arcpy.SpatialReference(utmZones[utmZone]) # Project line to correct UTM zone and add its length to the correct sum geom = row[0].projectAs(sr) if row[1] == "HDD": hLength += geom.length else: pLength += geom.length # Write data to CSV with open(output,'wb') as outFile: date = datetime.datetime.today() headers = ("Date","P Total Length (m)","H Total Length (m)") record = (str(date),str(plength),str(hlength)) writer = csv.writer(outFile) writer.writerow(headers) writer.writerow(record)
أكثر...