ArcGIS: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
Line 64: Line 64:


Python is supported in ArcGIS 9.x as a scripting language. (In fact some of the ArcToolbox tools are written in it.) This is nice because it's available cross-platform; if you learn Python you might not have ArcObjects on your Linux box but the language itself is probably already installed there so all the other features are available.
Python is supported in ArcGIS 9.x as a scripting language. (In fact some of the ArcToolbox tools are written in it.) This is nice because it's available cross-platform; if you learn Python you might not have ArcObjects on your Linux box but the language itself is probably already installed there so all the other features are available.
I can write a little teeny Python script and call it from ArcToolbox.
But I also want to add commands to ArcMap, like an entire extension...
how to do that?


==== Perl ====
==== Perl ====

Revision as of 23:30, 27 September 2005

ArcObjects

What is "ArcObjects"

A set of classes that provide an interface to ESRI's desktop GIS product.

How do I get started?

You might want to get a handle on Visual Basic first... or some object-oriented language anyway.

  • First take the ESRI Campus workshop "Getting Started with ArcObjects in ArcGIS"
  • Next try "Getting Started with Scripting in ArcGIS" - includes an intro to Python.
  • Next read the book "Getting To Know ArcObjects" (by Robert Burke)
  • If you did not already install the Devoper's Tools when you installed ArcMap on your computer, do that. Then go peruse the online help. (Start->Programs->ArcGIS->Developer Help->VB6 Help)

Both the workshop and the book are based on VBA. Any application (such as PowerPoint) or language (Python) that supports COM (or has VBA) can use ArcObjects.

VBA Toolkit CD - There is a toolkit CD available for free from ESRI. Mentioned in the ArcObjects course. I could not find mention of it on the Web site.

You can visit the ESRI Support Center Geoprocessing page

Many ESRI books are available from ESRI documentation library as PDF files. For example there is the book Writing Geoprocessing Scripts.

Python resources: The official Beginner's Guide to Python and the book for programners, Dive into Python (available online, PDF, or even on paper.)

What about older versions of ArcGIS? 8.3??

What if I don't have ArcGIS Desktop?

What if I want an application or tool to run on a Windows client that does not have ArcGIS installed?

What if I want a tool to run on a Linux system?

One solution to these problems is to use ArcGIS Engine; there are versions of ArcGIS Engine for both platforms. ArcGIS Engine can be embedded in your application so that you can use ArcObjects without having access to ArcGIS Deskstop.

Another is to base your GIS project entirely on open source; if that works for you, great. I have to write another page and link it in here though since this one is for ArcGIS.

ArcObjects containers

You can group tools for ArcCatalog into toolboxes called .tbx files. This is just a convenient way to handle them as groups in the ArcToolbox UI. The tools themselves still live in their .py files.

COM or ActiveX

Talking to ArcObjects requires the use of a programming language that supports COM (Common Object Model) or ActiveX. ESRI docs refer to COM but Microsoft now calls it ActiveX which is a much sexier name.

The theory is that any language that supports COM will work. The ones that ESRI actively promotes are VB, VBA, and (as of ArcGIS 9) Python.

VB and VBA

Use VB to create complete standalone executables. Or C++ or C#.

VBA is the version of VB that is embedded in other apps like ArcMap and Powerpoint. Use it to glue your own custom GIS functionality to those apps.

What about .NET?

ArcObjects does not require .NET; any language that supports COM can use ArcObjects. But you can do more with ArcWEB using .NET.

There is an ESRI campus workshop called "Migrating to VB .NET" where you can learn more about it. Using .NET requires Visual Studio .NET, which I don't have. That's that.

Python

Python is supported in ArcGIS 9.x as a scripting language. (In fact some of the ArcToolbox tools are written in it.) This is nice because it's available cross-platform; if you learn Python you might not have ArcObjects on your Linux box but the language itself is probably already installed there so all the other features are available.

I can write a little teeny Python script and call it from ArcToolbox. But I also want to add commands to ArcMap, like an entire extension... how to do that?

Perl

I just unsuccessfully did a Web search for anyone using Perl with ArcObjects. Hey, I could be first! (I doubt it! I think I have not found the right page yet.) All references I have found use Perl for things like string transforms or Web CGI applications. No COM / ArcObjects examples so far.

I don't have time (heard that before) to break ground here. It is easier to learn python.

Drop me a line if you have functional sample perl/ArcObjects code.

Sample ArcObjects applications

Check the Conversion Tools in ArcToolbox. Any tool with an "S" icon is a script. Right-click it and select "edit" to see the code. I have Python 2.4 installed so this does not work. But I can use the Properties dialog for the script, copy the file name from the Source tab and then open the file in PythonWin 2.4

gpstools GPS data processing

flightcheck - A utility to read an mxd file and to make creating a cdrom containing all data required

Stuff I'd like to work on

I'd like a tool that would help me build an ArcIMS file from an ArcMap project. Is there any functionality exportable from ArcIMS tools that I can use? I think they are using Web services instead of COM though.

I'd like a tool that would help me build a MapServer MAP file from an ArcMap project, too. I wonder if there is any Python class that would help me there?

How about that PCMapUtils tool eh? What about integrating something with its functionality into an ArcMap tool?

The stuff that the ArcPad tools can do is pretty limited. I wonder what could be done there? ArcPad is using XML as its project file language.

Misc

From the ArcGIS mailing list

Method to insert data entry forms

Eric O’ Neal

Make a new project, or open the macro editor of your old one, and add the form. After that, go back to the map and right click somewhere in one of the grey toolbars. Scroll down to 'Customize'. Click the 'Commands' tab at the top and change the "save in:" to 'your project' (not ' Normal.mxt'. In the left box, scroll down to 'UIcontrols'. Click 'New Control'.->>'Button Control' Drag the new button to a toolbar. Right click the new button and select 'View Source'. You will see the click event. type in:

'frm1.show'

The button should work now. You can make new Toolbars in the 'Customize' part and drag this button on to them if you want.

Lawrence Hartpence

The way that I have brought data entry forms into ArcGIS is by adding UIControls. In ArcMap, go to the "Tools" menu and then select "Customize". Select the "Commands" tab and scroll down to the "UIControls". After you select "UIControls", three buttons will appear below the pick list, click on the one that says "New UIControl..." A window will pop up with an array of different controls you may create. Choose new UIButton Control. Once this control is created, you will see it in a pick list on the Right side of the "Customize" window. Click on the new UIButton control and drag it to one of the toolbars. Once on the toolbar, right click on the button and in the menu which Pops up, choose "View Source". This takes you to VBA. You access the form by typing the form's name Then ".show (0)" in the Sub which is automatically set up for your UIButton control. It will look something like this: Private Sub UIButtonControl1_Click() QueryForm.Show (0) End Sub

Nick Seigal

(1) VBA is embedded in ArcGIS. You can access the Visual Basic Editor from the Tools menu. VBA has its own forms engine that is different from that in VB (more on that later). Much like in Excell or Access, you can create code and even forms that run like macros. These can be added by hand to the interface of a map document or even to the Normal template (so that they are available in all new Map Documents).

(2) VB6 is often used (although you could also use VB.Net, C++ or C#) to create what is called an "extension" to ArcMap. An example of this approach are ESRI's own extensions, such as Spatial Analyst. To add functionality to ArcMap in this way requires fairly advanced VB skills, although there are many small and fairly easily tweaked samples that you might get to work without having to mess with the extension sturcture. All you would need to do is have the Visual Basic 6 development environment on your machine and take an ESRI sample, add the VB form and data editing functionality you want to that extension framwork and compile the extension as a .dll file. Then, when this file is registered with Windows and with the ESRI COM Categories (ESRI Add Ins to VB6 help with these tasks), the fuctionality will Appear like magic in ArcMap.

(3) Model Builder can be used to create tools for ArcToolbox that use form-like interfaces and which do basic editing tasks. Check out the documentation on that tool for more details.