.mdb (personal geodatabase) to shapefiles programatically

1308
6
03-26-2014 09:06 PM
PrashantTiwari
New Contributor
Hi,
I have an mdb file which has a number of shapefiles. I can extract the shapefiles from the mdb file in the ArcMap 10.2 Desktop application. However I am experimenting with an Arcgis plugin and I am looking for a way to load the shapefiles from an mdb file programtaically. I am working in Visual Studio 2010 on C#. Is there a way to do that?
0 Kudos
6 Replies
NidhinKarthikeyan
Occasional Contributor III
You can use Python script.

FeatureClassToShapefile example (Python window):
import arcpy
from arcpy import env
env.workspace = "C:/data/airport.gdb"
arcpy.FeatureClassToShapefile_conversion(["county", "parcels", "schools"],
                                         "C:/output")


FeatureClassToShapefile example 2 (stand-alone script):
# Name: FeatureClassToShapefile_Example2.py
# Description: Use FeatureClassToGeodatabase to copy feature classes
#  to shapefiles
 
# Import system modules
import arcpy
from arcpy import env
 
# Set environment settings
env.workspace = "C:/data"
 
# Set local variables
inFeatures = ["climate.shp", "majorrds.shp"]
outLocation = "C:/output"
 
# Execute FeatureClassToGeodatabase
arcpy.FeatureClassToShapefile_conversion(inFeatures, outLocation)
0 Kudos
PrashantTiwari
New Contributor
Hi,

Thanks for the reply. The thing is I am a newbie when it comes to Python. Is there any way to do it via C#? Or if I do have to use the Python script, how do I use it?
0 Kudos
NidhinKarthikeyan
Occasional Contributor III
Use Python GUI or Python command line and enter the code mentioned above. Mention the path of Geodatabase under 'env.workspace' and provide the name of the Shapefile(output) in the last line of code.

I don't have any idea regarding C#. You might get suggestion from other users regarding  C#.

You should post this question in Developers Forum.
0 Kudos
VinceAngelo
Esri Esteemed Contributor
C# application development would be with ArcObjects, and the proper forum would be ArcObjects SDKs

- V
0 Kudos
PrashantTiwari
New Contributor
Hi Nidhin! So I tried my hands on Python and your script works perfect! The only issue I am facing now is that I have to provide the name of the shape file as parameters..Is there a way to simply extract all the shapefiles from the geodatabase file, like a foreach loop in C# or anything of that sort? Thanks in advance brother 🙂
0 Kudos
PrashantTiwari
New Contributor
Hey Vince! Thanks for the help man! Although I could not find what I was looking for exactly, I did find some really cool stuff on the forum to learn..much appreciated! 🙂
0 Kudos