copy shapefile to feature dataset ( within a .gdb)

764
4
Jump to solution
03-07-2022 10:52 AM
Chelsea_Trusdell
New Contributor

hello, 

For example, I have 3 .shp files ( points, polygon, polyline ) in a folder and within that folder, I also have a geodatabase with an empty point dataset.

how do I copy only the points shapefile into the point dataset within that geodatabase? i tried os.path.join but it doens't work. 

 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor
source_path = r'C:/folder name/homes.shp'
out_loc = r'C:/folder name/new.gdb/Points'
out_name = 'homes'

arcpy.FeatureClassToFeatureClass_conversion(source_path, out_loc, out_name)

 although it's a bit strange to resort to doing this in python, what are you actually trying to achieve?  Is this just a coursework question?

View solution in original post

0 Kudos
4 Replies
DavidPike
MVP Frequent Contributor

Is it a point FC in a FGDB or a Feature Dataset in an FGDB or a Point FC in a Feature Dataset?  Can you share your code?

0 Kudos
Chelsea_Trusdell
New Contributor

Chelsea_Trusdell_0-1646682933964.png

hmm, i haven't wrote the code yet but what i essentially want is to copy over the homes point shape file to the points dataset within the new.gdb. thanks for your help

0 Kudos
DavidPike
MVP Frequent Contributor
source_path = r'C:/folder name/homes.shp'
out_loc = r'C:/folder name/new.gdb/Points'
out_name = 'homes'

arcpy.FeatureClassToFeatureClass_conversion(source_path, out_loc, out_name)

 although it's a bit strange to resort to doing this in python, what are you actually trying to achieve?  Is this just a coursework question?

0 Kudos
by Anonymous User
Not applicable

David answered the same question here arcpy-import-data-into-feature-dataset back in 2020.

In short, you just add the dataset name in the path when you copy it in.

 

arcpy.CopyFeatures_management(homes.shp, r'C:\new.gdb\Points\homes')

 

note, they must be the same spatial reference.

0 Kudos