0

I'm looking to use a point on the map provided through a FeatureSet as an input to both a buffer and Select by Location. I have created the geoprocessing tool that works, but am having difficulty with getting this part to not provide errors.

inPts = arcpy.GetParameterAsText(0)  
distance = arcpy.GetParameterAsText(1)
arcpy.SetParameter(0, "sourcePt")
arcpy.MakeFeatureLayer_management("sourcePt", "sourcePt_lyr")

"inPts" is my FeatureSet. Distance is the field is the distance value for my buffer. When I try and make the feature layer, it is telling me that "sourcePt" has no data source.

Is there a step that I'm missing like needing to define geometry?

2

It doesn't look like 'sourcePt' does have a source, you're making up that variable in the expression.

The SetParameter function operates as follows: SetParameter (index, value) - (source), meaning that where you currently have 'sourcePt' should be an object.

Example:

inPts = arcpy.GetParameterAsText(0) 
distance = arcpy.GetParameterAsText(1)
arcpy.SetParameter(0, distance)

If 'sourcePt' does actually have a value associated with it (which from the code you've provided we cannot tell) then please include that as well.

Edit:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.env.workspace = "CURRENT"

csvFile = r"csv location"
arcpy.TableToTable_conversion(csvFile, "database file save location")

# Set the local variables
in_Table = r"database file save location"
x_coords = "x-coordinate header from csv"
y_coords = "y-cooydinates header from csv"
out_Layer = "layer name"
saved_Layer = r"lyr file location and name"
prjPath = "coordinate system location and name, if needed"
arcpy.MakeXYEventLayer_management (in_Table, x_coords, y_coords, out_Layer, prjPath)



# Add layer to mxd
arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
addLayer = arcpy.mapping.Layer(r"lyr file location and name")   #same as above
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")

# Buffer

see this

  • should I be using inPts as my value? It is the first user parameter for my tool and is the FeatureSet from the point. Or am I doing too many steps and can just use inPts in my buffer? – Daniel Katleman May 14 '18 at 20:33
  • What exactly is inPts, a shapefile, layer, etc. – Daniel Mutton May 14 '18 at 20:49
  • It is a feature set. It is just an empty point that can be put anywhere on the map that I want to be able to be used as an input to both a buffer and later select by location. – Daniel Katleman May 15 '18 at 2:31
  • In arcpy the buffer requires an in_feature, so as long as the feature set is physically saved on your mxd as a feature, you should be fine. As for the select by location you won't be using the feature set. Instead you'll likely use the out_feature_class from the buffer. I hope that helps. – Daniel Mutton May 15 '18 at 13:24
  • how would I save the FeatureSet to the mxd? If this is supposed to be a one click tool. I know I can maybe create a scratch workspace, but all I'm really looking to do is extract the x/y coordinates so that they can be converted to a point and then from there a feature class to be used as an input – Daniel Katleman May 16 '18 at 17:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.