Create Feature Field in Feature Class with possibility to add values Toolbox

242
2
Jump to solution
04-01-2021 03:07 AM
Nicola
by
New Contributor

Hello everyone,

I have a problem regarding a small python script for creating a toolbox in ArcGIS Pro. My aim is to create 3D Boreholes in a Scene Layer. For this purpose I first wanted the possibility for the user to enter values regarding the hight in a point feature class.

Until now I created the fields for the values. But now I cant find any solutions for creating the values for each line in the feature class. Should be possible for the user to enter them for each feature in the class...

If anyone knows a possiblity for doing something like this I would be very thankful for some input (where I can look for possible soultions or functions ect.).

import arcpy




arcpy.env.overwriteOutput = False


# Get Value from Raster
wells = arcpy.GetParameterAsText(0)
raster = arcpy.GetParameterAsText(1)

# Process: Extract Values to Points (Extract Values to Points) (sa)
Output_point_features = arcpy.GetParameterAsText(2)
arcpy.sa.ExtractValuesToPoints(in_point_features=wells, in_raster=raster, out_point_features=Output_point_features, interpolate_values="NONE", add_attributes="VALUE_ONLY")


#AddField FromDepth ToDepth

fieldName1 = "FromDepth"
fieldPrecision = 3
fieldAlias = "fromdepth"
fieldName2 = "ToDepth"
fieldPrecision2 = 3
fieldAlias2 = "todepth"

arcpy.AddField_management(Output_point_features,fieldName1, "LONG" , fieldPrecision,
field_alias=fieldAlias, field_is_nullable="NULLABLE")

arcpy.AddField_management(Output_point_features,fieldName2, "LONG" , fieldPrecision2,
field_alias=fieldAlias2, field_is_nullable="NULLABLE")

Thanks in advance and regards,

Nicola

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Honored Contributor

the parameters just need to be set properly in the parameter, For both, you would have to specify as a Text (string) parameter.  The downside, your people would have to enter the full path to the 'wells' and 'raster' and make sure it is 'raw' encoded .

A better method would be to let them navigate to the FeatureClass and to the raster on disk.

Entering other values as parameters like 'from depth' and 'to depth' you would specify 'float' or 'double' or even 'integer' as the data type.  The users can then specify the depths manually.  You then have to provide checks to ensure the correct data type and you would use the GetParameter option

GetParameter—ArcGIS Pro | Documentation

or convert to the appropriate data type if you are using GetParameterAsText


... sort of retired...

View solution in original post

2 Replies
DanPatterson
MVP Honored Contributor

the parameters just need to be set properly in the parameter, For both, you would have to specify as a Text (string) parameter.  The downside, your people would have to enter the full path to the 'wells' and 'raster' and make sure it is 'raw' encoded .

A better method would be to let them navigate to the FeatureClass and to the raster on disk.

Entering other values as parameters like 'from depth' and 'to depth' you would specify 'float' or 'double' or even 'integer' as the data type.  The users can then specify the depths manually.  You then have to provide checks to ensure the correct data type and you would use the GetParameter option

GetParameter—ArcGIS Pro | Documentation

or convert to the appropriate data type if you are using GetParameterAsText


... sort of retired...

View solution in original post

Nicola
by
New Contributor

Thanks a lot for your help!

I now used the method with letting them navigate to FeatureClass and raster! 

 

 

0 Kudos