Select to view content in your preferred language

Select features by attribute, IS NOT NULL

458
1
07-17-2023 03:15 PM
CCWeedcontrol
Regular Contributor

I need to copy features that are not Null. I need to use the arcpy.management.CopyFeatures because I am doing a join, that is one to many. The issue I am having is that my query to select "IS NOT NULL" doesn't work. I don't get an error, what is the correct syntax for this query?

 

Source = "Parcels"

Lyr = "Par"
fieldName = "TAXID"
select = """{0} IS NOT NULL""".format(fieldName)
arcpy.management.MakeFeatureLayer(TAXSource, Lyr)
arcpy.SelectLayerByAttribute_management(Lyr, "NEW_SELECTION", select)
arcpy.management.CopyFeatures(Lyr, "C:Temp/test.gdb/TestPar")

 

Lyr = "TaxPar"
#fieldName = "TAXID"
select = "TAXID IS NOT NULL" #"'TAXID = IS NOT NULL'"
arcpy.management.MakeFeatureLayer(TAXSource, Lyr, select)
arcpy.management.CopyFeatures(Lyr, "C:Temp/test.gdb/Testpar")

 

0 Kudos
1 Reply
TylerT
by
Occasional Contributor III

try:
select = ' "TAXID" IS NOT NULL '

Note: Your above code states two different Lyrs.   Note the docs have caveats regarding existing queries on your layer that might affect results (https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-feature-layer.htm).

Tyler

0 Kudos