1

I have been trying to develop a master script to go through a series of geoprocessing tools and executing them. I am trying to generate a TIN and contours from a raw xyz file. Below is a very simple script that integrates the various tools. I am having difficulty inserting the correct inputs and outputs for the TIN generation and Surface Difference calculation/generation. Let me know if i am missing an input/output specification or a simple default value. I tried doing this same workflow on Model Builder to then export its python script, however i was unable to execute a successful TIN Output since for some reason only allowed for a Raster Output.

Note: I decided not to insert variables, i went directly to its filename.

import arcpy, exceptions, sys, traceback
from arcpy import env
from datetime import datetime

start_time = datetime.now()
print "The program has began processing", start_time


try:
    #Enables ArcGIS 3D Toolbox
    arcpy.CheckOutExtension("3D")
    #Set workspace
    env.workspace = "C:\Standalone"
    #Set Spatial Reference using Well-Known ID  NAD 27 State Plane Missouri East FIPS
    sr = arcpy.SpatialReference(26796)
    #XYZ Processing to Point Shapefile
    arcpy.ddd.ASCII3DToFeatureClass("004d1214_3x3.xyz", "XYZ","004d1214_el.shp", "POINT", "1",sr,)
    arcpy.AddMessage("Processing Complete")


    #Add XY Coordinates 
    in_features = "004d1214_el.shp"
    arcpy.AddXY_management(in_features)

    #Create TIN surface out of the generated point shapefile
    arcpy.ddd.CreateTin_3d("tin004d1214_el",sr,"C:\Standalone\004d1214_el.shp POINT_Z Mass_Points <None>","DELAUNAY")

    #Delineate TIN Area. Verify that maximum edge length is greater than the point spacing.
    arcpy.ddd.DelineateTinDataArea("tin004d1214_el", 10, "ALL")
    arcpy.AddMessage("Complete")

    #Trigger Surface Difference to yield new elevation, Insert optional directories for TIN output
    inSurface = "tin004d1214_el"
    inReference = "CLASSIFIED PATH DIRECTORY"
    outTin = "tin004d1214_lrp"
    outPoly = arcpy.CreateUniqueName("004d1214_lrp.shp")
    arcpy.SurfaceDifference_3d(inSurface,inReference,"C:\Standalone\004d1214_lrp.shp",outTin) #Check for syntax

    #Generate Surface Contours off the Reference Survey surface
    arcpy.SurfaceContour_3d(outTin,"004d1214_contours.shp")  #Check for contour field add


except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
            .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)

end_time = datetime.now()
print ('Duration: {}'.format(end_time - start_time))
  • Have you been through the steps in catalog? Do you have the 3d extension? Is it switched on? If you're not running this in catalog the script may be unaware of your 3d analyst license. Are there any error messages? If so I'd like to see them... at a glance this script looks very good, it's probably something outside the script causing issues. – Michael Stimson Mar 12 '15 at 22:52
  • 1
    I don't like single '\' in folder and output names – FelixIP Mar 13 '15 at 5:39
  • I agree with @FelixIP that the first thing will be to fix those single '\' - gis.stackexchange.com/a/65213 - but then I think you should cut your script back to a Python snippet that works up to where you first start to see something going astray, and provide more details e.g. error message, output not being created, etc – PolyGeo Mar 13 '15 at 7:23
  • After numerous debugging attemps, it only runs up until the shapefile creation and adding its xyz coordinates to it. The code in between create TIN and the last print statement gets ignored. I don't know its the 3D license since i was able to process the XYZ file to feature class. – user40720 Mar 13 '15 at 13:31
  • Can anyone shed some more light on this? – user40720 Mar 16 '15 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.