arcpy notebook problem where clause for select analysis?

526
5
Jump to solution
02-09-2022 12:14 AM
JohannesBierer
Occasional Contributor III

I have problems in ArcGIS Pro 2.8 notebooks with a where clause of two long fields of a file geodatabase feature class (FID fields after union):

 

where_clause_1 = '("FID_outBarriereBuffer" = -1 AND "FID_Nutzung_Weide" > -1)'
arcpy.analysis.Select(inBarriere, outWeide, where_clause_1)

 

With this I get the following message:

ExecuteError: ERROR 000358: Ungültiger Ausdruck ("FID_outBarriereBuffer" = -1 AND "FID_Nutzung_Weide" > -1)
Fehler beim Ausführen von (Select).

Any ideas for a solution?

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

I would do the query manually to and copy the snippet to make sure the right sql variant is used for the inputs

Select (Analysis)—ArcGIS Pro | Documentation


... sort of retired...

View solution in original post

5 Replies
JohannesBierer
Occasional Contributor III

If I use select layer by attribute and copy feature there is no problem?

arcpy.management.MakeFeatureLayer(outUnion, outUnionLayer)

arcpy.management.SelectLayerByAttribute(outUnionLayer, 'NEW_SELECTION', 
                                        '"FID_Nutzung_Weide" > -1 And "FID_outBarriereBuffer" = -1')

arcpy.management.CopyFeatures(outUnionLayer, outWeide)
0 Kudos
DanPatterson
MVP Esteemed Contributor

I would do the query manually to and copy the snippet to make sure the right sql variant is used for the inputs

Select (Analysis)—ArcGIS Pro | Documentation


... sort of retired...
JohannesBierer
Occasional Contributor III

Thank you for your good idea. It leads then to something like this (if I build a model and export to python):

arcpy.analysis.Select(in_features=outUnion, out_feature_class=outUnion_Select, where_clause="FID_Nutzung_Weide > -1 And FID_outBarriereBuffer = -1")

but doesn't work in the notebook.

Think I will use the select by attribute  + copy feature solution to get to an end ...

 

0 Kudos
by Anonymous User
Not applicable

Maybe try it without the ( ).

JohannesBierer
Occasional Contributor III

you are right the () are useless, I put them in out of despair because without it doesn't work as well 🙂

0 Kudos