top of page

Copy Certain Feature Classes​​

The Python script reads all the feature classes in a personal or file geodatabase and copies only the polygon feature classes to a new file geodatabase.

 

# Ehsan Momeni

from arcpy import env, ListFeatureClasses, Describe, Exists, CreateFileGDB_management, CopyFeatures_management
from os import path

Input_path = r"C:\Users\emomeni\data"
Output_path = r"C:\Users\emomeni\output/"

env.workspace = Input_path  # setting the environment for input path
env.overwriteOutput = True  # setting the environment for overwrite

GDB = "New_Geodatabase.gdb"​

if Exists(Output_path+GDB):  # creating a new geodatabese
    print ('\t%s is exist.\n' % GDB)
else:
    CreateFileGDB_management(Output_path, GDB)
    print ('\t%s is created.\n' % GDB)

for fc in fclist:
    if Describe(fc).shapeType == "Polygon":
        outFeatureClass = path.join(Output_path + GDB, fc.strip(".shp"))
        CopyFeatures_management(fc, outFeatureClass)
        print ("\t%s is copied successfully." % fc)

 

google_scholar1-300x150.png
ResearchGate.png
Ehsan Momeni ORCID GIS Remote Sensing Ur
Ehsan Momeni LinkedIn GIS Remote Sensing
ncbi-300x150.png
academia.png

(Information on this website may not be up to date)

bottom of page