import arcpy
import os
arcpy.env.workspace=r'C:\Users\alanamms\Documents\ArcGIS\Projects\MyProject8\MyProject8.gdb'
cw=os.getcwd()
infc=os.path.join(cw,'MyProject8.gdb','limite_ac.shp')
outfc=os.path.join(cw,'MyProject8.gdb','result.shp')
buffer=arcpy.Buffer_analysis('infc','outfc','1000 kilometers')
The error is below
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 1131, in Buffer
raise e
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 1128, in Buffer
retval = convertArcObjectToPythonObject(gp.Buffer_analysis(*gp_fixargs((in_features, out_feature_class, buffer_distance_or_field, line_side, line_end_type, dissolve_option, dissolve_field, method), True)))
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset infc does not exist or is not supported
Failed to execute (Buffer).
Solved! Go to Solution.
I can't seem to find a way to format python code in a reply so I'll do the best I can. You don't need the os module if you are working with file geodatabses. Just set the workspace env: everything you do can then comes from and goes to that workspace with arcpy:
import arcpy
arcpy.env.workspace = r'C:\path\to\your.gdb'
inFC = 'YourFeatureClassName'
outFC = 'TheOutFeatureClassName'
arcpy.Buffer_analysis(inFC, outFC, '1000 Kilometers')
Please, when posting code use the format tool .
It looks to me that you are joining the current working directory to the field geodatabase and then a shapefile. Actual shapefiles do not and cannot reside within a file geodatabase.
So the trouble is the extension of the file? My real intention is to call the file without the need to add it, just making reference to it. (I thought the method os.path.join would solve it)
How could I do that?
Is your data stored as actual shape files or as feature classes with a file geodatabase? If the former, they are stored in a folder as a series of files with the same name but different extensions. The .shp extension is just one of them.
On the other hand if you are storing your data in a file geodatabase (best practices) there is no extension, just the feature class name.
Until you can explain where and how you have your data stored, there's not much I can help you with.
Sorry my confusion,but im begginer lmao. My files are stored in the geodatabase.
I can't seem to find a way to format python code in a reply so I'll do the best I can. You don't need the os module if you are working with file geodatabses. Just set the workspace env: everything you do can then comes from and goes to that workspace with arcpy:
import arcpy
arcpy.env.workspace = r'C:\path\to\your.gdb'
inFC = 'YourFeatureClassName'
outFC = 'TheOutFeatureClassName'
arcpy.Buffer_analysis(inFC, outFC, '1000 Kilometers')