I am trying to create an empty feature class in the projects folder directory, but I get the following error.
How can use arcpy.management.CreateFeatureclass to create an empty feature class in the projects folder?
import arcpy
import os, sys
import time
from arcpy import env
t1 = time.time()
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
lyr = m.listLayers("Soil")[0]
arcpy.env.workspace = os.path.dirname(aprx.filePath)
wp = os.path.dirname(aprx.filePath)
outPath = wp
NewLyr = "Soils_New"
template = "Soil"
out_fc = arcpy.management.CreateFeatureclass(outPath, NewLyr, template)
Error
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 3451, in CreateFeatureclass
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 3448, in CreateFeatureclass
retval = convertArcObjectToPythonObject(gp.CreateFeatureclass_management(*gp_fixargs((out_path, out_name, geometry_type, template, has_m, has_z, spatial_reference, config_keyword, spatial_grid_1, spatial_grid_2, spatial_grid_3, out_alias), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 160142: The Field type is invalid or unsupported for the operation.
Failed to execute (CreateFeatureclass).