Select to view content in your preferred language

import shapefiles to feature datasets according to shape types

642
2
04-12-2023 03:08 PM
Labels (3)
SoknaLy
New Contributor II

Hi there,

I have multiple folders consisting of many shapefiles of different shape types (point, line, polygon). I have created a geodatabase and three feature datasets (point, line, polygon) in it. All i want to do is to ask python to loop through each folder and describe shape type then import shapefiles to their respective feature datasets. I finished the first and second steps, but the last one (importing shapefiles to their respective feature datasets) is tricky for me. Any ideas or suggestions on that are much appreciated. 

Thanks.

0 Kudos
2 Replies
Clubdebambos
Occasional Contributor III

Hi @SoknaLy 

Using arcpy.Describe() function you can access the shapeType property of a Shapefile/Feature Class

See this link in the ESRI documentation with an example code snippet.

You can use the shapeType property to direct each Shapefile into the correct feature dataset using if/else statements.

~ learn.finaldraftmapping.com
0 Kudos
RhettZufelt
MVP Notable Contributor

Rather than "importing" you can loop through your list of shapefiles and feed that to arcpy.conversion.FeatureClassToFeatureClass to the appropriate feature dataset.

R_