1

I have script that I run quite regularly in the python window of Arcmap 10.2.2 and am in the process of converting it to a toolbox script so that others can use it more easily.

It uses select layer by location a number of times, for example:

arcpy.SelectLayerByLocation_management(Contours_G_1m, "CONTAINS", peakpoints)

It worked fine in the python window but now that its in a tool it fails with

Parameters are not valid. ERROR 000368: Invalid input data

This is not at all surprising because this tool works on a layer and the script does not add a layer to the map when it creates a new feature class.

Is there any way of selecting the feature in a shapefile rather than a layer by location, or a workaround for using this tool in a script?

1

the input data of selectlayerbylocation is a layer. When you take it from ArcGIS python Windows, the feature class is already accessed through a layer, but with a stand alone script it is necessary to create the layer first.

This can be done with MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info})

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.