Can you please take a look at this demo and let me know why I am not able to create new feature class from a shapefile based on selecting by attribute and saving the new feature class in a Geodatabase?

The file is adding to the GDB but it is empty on attributes and geometry.

# Import arcpy module
import arcpy    

# Local variables:
Dataset = "D:\\GIS\\TPK\\src\\New Folder\\lui.gdb\\Dataset"
Louisiana = "Louisiana"
Louisiana__3_ = Louisiana
mm = "D:\\GIS\\TPK\\src\\New Folder\\lui.gdb\\Dataset\\mm"

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(Louisiana, "NEW_SELECTION", "\"NAME_2\" = 'Acadia'")

# Process: Create Feature Class
arcpy.CreateFeatureclass_management(Dataset, "mm", "POLYGON", "Louisiana", "DISABLED", "DISABLED", "", "", "0", "0", "0")
  • 1
    Use copyfeaures instead of create. – FelixIP Oct 12 '18 at 19:06
  • 1
    Use Select instead of SelectLayerByAttribute and CreateFeatureClass. – PolyGeo Oct 12 '18 at 19:12

CreateFeatureClass creates an empty feature class as you have observed.

I recommend using the Select_analysis tool instead of SelectLayerByAttribute and CreateFeatureClass.

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.