CreateTIN with arcpy using more input feautures

1933
5
Jump to solution
03-15-2017 08:42 AM
martinaraffellini
New Contributor II

Hello!

I am writing a Python code and the function createTIN does not work if i use 2 input features but i need both of them.

This is the code (the workspace is defined before):

area = 'Model_Area.shp'  # a polygon to clip the TIN
data = 'IST_HQ100_Depth.shp'  # the .shp with the height field i need
dField = 'Field4'
TIN = output + "tin"    # the folder is specified above

Input_Features = "{0} {1} Mass_Points <None>".format(data, dField)
inArea = "{0} <None> Soft_Clip <None>".format(area)

arcpy.CreateTin_3d(TIN, CoordSys, [Input_Features, inArea])‍‍‍‍‍‍‍‍‍

The syntax in the DesktopHelp fore more inputs has squared brackets and comma like i did.

If i give only one input (which is the example in the DesktopHelp) it works, but the output is wrong.

With both inputs in the ArcMap GUI it works with no problem (picture) and result is correct.

I really need to code it because I will put data and dField in a for loop for many data.

Does anybody know what the mistake could be? Pleeease help me if you can

I am using Python 2.7 and ArcMap 10.3, which should be compatible

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
IanMurray
Frequent Contributor

Also, just found another thread with a similar question which might be of use to you.

https://community.esri.com/thread/161119

View solution in original post

5 Replies
IanMurray
Frequent Contributor

Hi Martina,

Please see about /blogs/dan_patterson/2016/08/14/script-formatting?sr=search&searchId=9aaf3fd8-05d9-4bb9-b3ee-4e83caf...‌ about posting code in GeoNet, for clarity's sake.

Have you tried going to the geoprocessing results in ArcMap and copying the results as a Python Snippet?  The snippet should give you a better idea on how you need to format your Input Feature Class parameter for the tool in Python. 

I'm guessing based on the tool help it would need to be a list of lists, with comma separated values for each Input Feature.

[['IST_HQ100_Depth.shp'   , 'Field4' , "Mass_Points" , None],['Model_Area.shp', None, 'Soft_Clip' , None]]

Also if you are working in Python, make sure you are setting your environmental settings so it knows where to look for your input features, or use fully qualified file paths to the files.  Also I never see where you define the variable TIN in your script.

Hope this helps some.

Ian

0 Kudos
martinaraffellini
New Contributor II

Dear Ian,

Thanks very much for advice! I am new to Python and the community...

I update my question according to this.

i will try with the snippets , but i am sure i should not use commas there

because there are no commas in the desktopHelp example. The example has

unfortunately only one feature as input...

If you have more suggestion i am always happy to read

Have a nice day!

martina

2017-03-15 17:04 GMT+01:00 Ian Murray <geonet@esri.com>:

GeoNet <https://community.esri.com/?et=watches.email.thread>

Re: CreateTIN with arcpy using more input feautures

reply from Ian Murray

<https://community.esri.com/people/iamurray?et=watches.email.thread> in *ArcGIS

API for Python* - View the full discussion

<https://community.esri.com/message/673042-re-createtin-with-arcpy-using-more-input-feautures?comment...>

0 Kudos
IanMurray
Frequent Contributor

It's true in the example they just use a single string with space seperated values.  I recommended differently for multiple inputs due to the help for that input showing the parameters as such:

in_features [[in_feature_class, height_field, SF_type, tag_value],...]

However, seeing as the input for the parameter is a Value Table, I believe you are right it needs to be a space delimited single string.  I'm finding the help for that parameter a little misleading and it probably should be updated to show multiple features better.
0 Kudos
IanMurray
Frequent Contributor

Also, just found another thread with a similar question which might be of use to you.

https://community.esri.com/thread/161119

martinaraffellini
New Contributor II

this works!! thanks

0 Kudos