0

DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far…

I am facing a quite interesting requirement:

"run python scripts within an ArcGIS Runtime app".

checking the concepts in the ArcGIS Resources for ArcGIS Runtime SDK for WPF i can read:

Geoprocessing in the runtime provides you with a framework for answering your GIS questions. The API works with geoprocessing though geoprocessing service tasks. These tasks are either hosted online, through an ArcGIS Server, or can be hosted locally, by providing the local server with a runtime enabled geoprocessing package (GPK).

Geoprocessing services can host one or more tasks, which come from a tool, script, or model, authored in ArcGIS for Desktop and then published to ArcGIS for Server or packaged as a geoprocessing package

but also I can read the following statement

Not all geoprocessing tools or functionality are supported in the runtime local server. Please see the supported geoprocessing tools list.

a few lines after is the next statement:

Python scripts Python is an open-source, general-purpose programming language used as a scripting language in ArcGIS geoprocessing. Python scripts can be shared for use with the runtime as geoprocessing packages. Scripts can be turned into script tools, and then packaged into a geoprocessing package. The ArcGIS Runtime contains its own imbedded Python

I understand that I can run python scripts using the geoprocessing packages, but not all the functionality that I can get from ArcPy library is available, Am I wrong?

is there a known workaround that allows to run python scripts? (with out using ArcObjects, just ArcGIS Runtime)

1 Answer 1

3

Correct. You can run Geoprocessing tools. You can write your own Geoprocessing tools in Python, create Geoprocessing packages, and run them in Runtime. Runtime comes with what we call "mini Python" at Esri, which is derived from the stock python.org Python for Windows install but reconfigured a bit so it doesn't require any set registry keys or administrative access to install. It's completely standalone when initialized from a Runtime app. It also has a few other modifications like the standard library is compiled into .pyc files and included as a .zip to save disk space. I wish I could have made it smaller so Python wasn't an optional part of a runtime configuration, but I think shrinking Python 2.7 down to about 11 megs without losing any functionality isn't too shabby. You could even include third-party modules in your distribution of runtime apps if you put them in the right place.

You could theoretically run any arbitrary Python code by creating a new geoprocessing script tool that tool one string argument (a path to a .py file) and was the following script:

filename = arcpy.GetParameterAsText(0)
execfile(filename, {'__file__': filename})

You may want to do your standalone Python on ArcEngine, though, as you get more tools and it was designed to be easier for developers and users to do this kind of thing. Runtime is more suited for small desktop applications and not as a full environment for developing Python scripts.

8
  • Hi, it is kind of weird....if i use this approach either from ArcGIS desktop or a Python IDE, the scripts run perfectly, but when i try to use it from a geoprocessing package....all i get is an Error. I tried to implement an exception estrategy to know the error...but it does not show anything but..."Fail"
    – XtianGIS
    Commented Nov 5, 2013 at 15:03
  • No error message at all? Does the same package run from desktop? I'd really strongly recommend using ArcEngine, this isn't really what Runtime WPF was designed for. Commented Nov 5, 2013 at 15:09
  • No Error....just... "Fail". I check in the log from the local server...and nothing at all.
    – XtianGIS
    Commented Nov 5, 2013 at 21:48
  • And that build of the runtime you checked to include Python? Commented Nov 5, 2013 at 21:49
  • 1
    Something that worries me, is the future of ArcEngine....the rumors says that it will be removed...as well as ArcObjects SDK.....thats the reason to use ArcGIS Runtime
    – XtianGIS
    Commented Nov 5, 2013 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.