The Stack Overflow podcast is back! Listen to an interview with our new CEO.
8

Instead of "C:\\temp\M0TASHT\M0TASHT.gdb\sLine" you need to double all your back slashes to escape them i.e. "C:\\temp\\M0TASHT\\M0TASHT.gdb\\sLine" And instead of where_clause = '"ManholeSubtype" = ('"4515" ')' Try where_clause = ' "ManholeSubtype" = ' + " '4515' " Or where_clause = ' ' ' "ManholeSubtype" = 4515 ' ' ' Which will ...


7

SelectLayerByLocation requires a Layer to select features, you can't select features directly on a feature class, which is what your script is trying to do. The reason it worked in ArcMap is because in ArcMap you were referencing the map layers rather than feature classes. Add a MakeFeatureLayer and set your SelectLayerByLocation to select that. for grid ...


6

The Make Feature Layer tool needs two parameter values, and you are only supplying one. MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info}) Try replacing: citiesLyr = arcpy.MakeFeatureLayer_management(cities) pnrsLyr = arcpy.MakeFeatureLayer_management(pnrs) selection = arcpy.SelectLayerByLocation_management("...


6

If you read the syntax section of the select by location tool you will see that it takes Feature Layers as inputs. A string which is a path to a shapefile is not a Feature Layer object. If you think about it how can you represent a selection of polygons with nothing more that a full path string to some file? A Feature Layer has this ability, it is called a ...


5

SelectLayerByLocation_management input must be a feature layer, so make one from the shp file first, then pass that into the method. NewLinks = "NewLinks.shp" Buffer = "Buffer.shp" arcpy.MakeFeatureLayer_management(NewLinks, 'newlinks_lyr') arcpy.SelectLayerByLocation_management('newlinks_lyr', "COMPLETELY_WITHIN", Buffer, "", "NEW_SELECTION", "NOT_INVERT")...


4

I realized that my problem was coming from the extra step of trying to dynamically recreate a layer for every entry in Spec_Layers. This value was being set from a multivalue input in the tool, which returns a list of objects which are already instantiated as Layer objects (so, no need to make a layer out of a layer). This is working for me nicely: (...


3

If you look at the arguments of arcpy.SelectLayerByLocation_management, which is SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}, {invert_spatial_relationship}), you will find that it expects a Selecting Layer, where it complains as in your error message. In your code, "Address" is a ...


3

The help state, regarding Make Feature Layer, that: the layer that is created by the tool is temporary and will not persist after the session ends Simply change the following variables... Pts_Lyr = scratchWorkspace + "/Pts_Lyr.lyr" Map_Layer = scratchWorkspace + "/Map_Layer.lyr" Prism_Lyr = scratchWorkspace + "/Prism_Lyr.lyr" to... Pts_Lyr = "...


3

I recommend that you create currentlayer using arcpy.MakeFeatureLayer instead of arcpy.mapping.Layer.


2

Select layer by location (or attributes for that matter) must be run on a layer. It's possible that when you exported it, some files were moved around that resulted in this error message. But without seeing the rest of the code, it's difficult to say. Could you edit your first post to include everything up to line 28? You might find this helpful. Edit: ...


1

A is a feature class (think what you see in ArcCatalog). You can't perform a selection on a feature class. You need to create a layer (think what you see in the ArcMap table of contents, with symbology and other unique aspects) from your feature class before you can apply a selection to it. fc = = r"//FILES/UNIXHome/Git/waterbirds_project/data/OS_waterways....


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})


Only top voted, non community-wiki answers of a minimum length are eligible