Select to view content in your preferred language

Select Layer By Location gives ERROR 000840: The value is not a Boolean

2201
6
09-14-2018 04:34 AM
georgemam
Emerging Contributor

I use ArcGIS 10.3

I have two layers : Project\project.DBO.Qo and Project\project.DBO.Poly. I want to select Project\project.DBO.Qo objects.

I got this error in Python Console: 

print arcpy.Describe(r"Project\project.DBO.Qo").shapeType
Point
print arcpy.Describe(r"Project\project.DBO.Poly").shapeType
Polygon

arcpy.SelectLayerByLocation_management(r"Project\project.DBO.Qo", "WITHIN", r"Project\project.DBO.Poly")
Runtime error  Traceback (most recent call last):   
File "<string>", line 1, in <module>   File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 7279, in SelectLayerByLocation     raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Boolean. Failed to execute (SelectLayerByLocation).‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

But Select By Location... in graphical user interface of ArcGIS works fine with the same layers.

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

You need layers.. try MakeFeatureLayer in your code

0 Kudos
georgemam
Emerging Contributor

I've tried, but the same error:

>>> arcpy.MakeFeatureLayer_management(r"Project\project.DBO.Qo", "Qolyr")
<Result 'Qolyr'>
>>> arcpy.MakeFeatureLayer_management(r"Project\project.DBO.Poly", "Polylyr")
<Result 'Polylyr'>
>>> 
>>> arcpy.SelectLayerByLocation_management("Qolyr", "WITHIN", "Polylyr")
Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 7279, in SelectLayerByLocation     raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Boolean. Failed to execute (SelectLayerByLocation). 
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Cross posted to SE:  arcgis 10.3 - Select Layer By Location gives ERROR 000840 ({select_features} as arcpy.Polygon) - Geo...   The OP's final comment at SE is:

I experimented with different layers and overlap_types. It comes out that from Python console Select By Location doesn't work
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If Poly you are using in the code snippet above was created using the code you have posted at SE:

poly = arcpy.Polygon(arcpy.Array([p1, p2, p3, p4]))

Then your issue could be tied to the fact you have not defined a spatial reference when creating the polygon.  Check to make sure all of your feature classes have valid spatial references.

0 Kudos
georgemam
Emerging Contributor

No Poly is a another layer. I experimented a lot with layers.

Why Select By Location doesn't work in Python console ?

By the way in ArcGIS Help we read:

poly = arcpy.Polygon(arcpy.Array([p1, p2, p3, p4]))
arcpy.SelectLayerByLocation_management("Qolyr", "WITHIN", poly)

Qolyr is a point object layer.

So arcpy.Polygon is feature class, right ? Is everything OK with this code snippet ?

Thanks for your attention !

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

arcpy.Polygon is not a feature class, it is an ArcPy Polygon object.  Most geoprocessing tools that operate on features with geometries will also accept either an ArcPy geometry or a list of ArcPy geometries, but that doesn't make an ArcPy geometry object a feature class or feature layer.

It is best practice to use a spatial reference when building ArcPy geometries.  Although Select Layer By Attribute may work when the selection features don't have a spatial reference, the user is taking a risk because projection on the fly cannot work without a spatial reference assigned, which introduces the chance results won't be accurate if projections of the dataframe or other layers are changed.

Unless you can share some subsets of your data, even just cleanse so only geometries remain, I am all out of ideas.  I regularly use arcpy.SelectLayerByLocation_management without incident, and I am sure many other ArcGIS users do as well.  ArcGIS 10.3 is an older product about to enter Mature Support.  It could very well be there was a bug in 10.3 that has since been addressed in a subsequent release.