Calling Python From C#

11 Mar

I have been programming ArcGIS Desktop Explorer in C#. My C# is not very good but my python is. I figured out that I can do minimal work in C# by calling python and just returning the results. I use Process.Start().

Why use python? Besides being better at it, because it allows access to all my ArcPy tools. That’s right, I can have a button in Desktop Explorer that allows the user to click it and run analysis on layers in their map.

I have several machines with Desktop Explorer. They are loading layers from remote machine on the network. This machine also has ArcMap and python. The buttons in Desktop Explorer call the scripts on this machine. Requiring only one install of python with all the additional libraries loaded. And one license of ArcMap to call ArcPy.

This works great for real time GIS too. Desktop Explorer can refresh a layer on command or at intervals of 1 minute. I link all the Desktops to a layer on the remote machine and set the refresh to 5 minutes. I have a python script that is running as a scheduled task that reads data from remote sources and writes out the shapefile every 3 minutes. The user and application dont know anything about how the shapefile is created and dont care, they just load the newest data as it comes in. And where I need temporary data, I link straight to the database and load it as notes.

Lastly, if I need to fix or change anything, instead of modifying the plugin and sending it to each machine I can just change the python file and all machines are automatically updated.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: