ArcPy: Import data into Feature Dataset within Geodatabase

274
7
07-09-2020 11:28 PM
BrianSteiner1
New Contributor II

I have a Geodatabase-file "mygdb.gdb" with a Feature Dataset therein, "mygdb.gdb\fds". How can I move files into that Feature Dataset with ArcPy? Please see picture: I want to move the shapefile "myshp.shp" and the raster "myraster" into that Feature Dataset with ArcPy.

Example of data to insert into Feature Dataset

0 Kudos
7 Replies
DanPatterson
MVP Honored Contributor

The requirements and data types are listed in the help

Feature datasets in ArcGIS Pro—ArcGIS Help | Documentation 


... sort of retired...
0 Kudos
BrianSteiner1
New Contributor II

On that page, I can't find any information about how to handle Feature Datasets with ArcPy. Where is a description how to move an external shapefile or raster into the Feature Dataset with an ArcPy-command?

0 Kudos
JoeBorgione
MVP Esteemed Contributor
0 Kudos
BrianSteiner1
New Contributor II

This explains how to move shapefiles into a geodatabase (in my example: mygdb.gdb). However, I don't understand how to move shapefiles into a Feature Dataset within a geodatabse (in my example: mygdb.gdb\fds).

0 Kudos
DavidPike
MVP Frequent Contributor
import arcpy

#path to input shapefile to be transferred to fgdb feature dataset
in_shp = r'C:\myshapefile.shp'

#path to output fc within feature dataset
#will likely error if .shp and feature dataset have different projections
out_fc = r'C:\mygdb.gdb\myfeaturedataset\myfeatureclass'

#run copy features tool
arcpy.CopyFeatures_management(in_shp, out_fc)
BrianSteiner1
New Contributor II

Thank you David Pike. I understand from your answer that the Feature Dataset within a Geodatabase is for Feature Files of same projection only. It is neither for Feature Files with another projection nor for Raster Files. My problem was, that I was trying to import a Raster File which is not allowed.

0 Kudos
DanPatterson
MVP Honored Contributor

That information was on the link I sent


... sort of retired...