Skip to content

Instantly share code, notes, and snippets.

@glw
Created December 24, 2014 18:05
Show Gist options
  • Save glw/d914859bc2799dc86871 to your computer and use it in GitHub Desktop.
Save glw/d914859bc2799dc86871 to your computer and use it in GitHub Desktop.
Batch export from ArcSDE to shapefile
# Name: arcsde-to-shp.py
# Description: Copies data from ArcSDE, converts it to shp file format and puts into destination folder
# Author: Garret Wais
import arcpy, os
from arcpy import env
arcpy.env.overwriteOutput=True
#set OS working directory
os.chdir("T:\\")
#Make GIS Directory
directory1 = "T:\\ElevationData"
directory2 = "T:\\PlanimData"
if not os.path.exists(directory1):
os.makedirs(directory1)
if not os.path.exists(directory2):
os.makedirs(directory2)
#creating FGDB
#arcpy.CreateFileGDB_management("T:/", "GISDATA.gdb")
#set ARCPY workspace #1
arcpy.env.workspace = "Database Connections\\connection\\to.GIS.featuredataset"
#if arcpy.Exists(r"Database Connections\\connection\\to.GIS.featuredataset"):
# print("OK!")
#to creat database connection
#arcpy.CreateDatabaseConnection_management("Database Connections","database name","SQL_SERVER","sql server name","DATABASE_AUTH","user name","password","SAVE_USERNAME","your name for database","#","TRANSACTIONAL","sde.DEFAULT")
#list of feature classes in planim
fcList = arcpy.ListFeatureClasses()
for f in fcList:
arcpy.FeatureClassToShapefile_conversion(f, directory2)
#set ARCPY workspace #2
arcpy.env.workspace = "Database Connections\\planim.sde\\planim.GIS.Topography"
#list of feat
fcList2 = arcpy.ListFeatureClasses()
for f in fcList2:
arcpy.FeatureClassToShapefile_conversion(f, directory1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment