Dealing with Data
[Part 3 of 12]

In this part, we're going to look at how we access data inside ArcGIS. To do this we need to drill down through a series of objects nested inside each other, starting with the Application object, asking each object for one closer to the data.

First, then, we need to get hold of an individual Layer in our map, holding the data. To do this, we first need to get hold of a map.

Screenshot: A slide from the powerpoint

Getting a Map/Layer (powerpoint)

Further info:

Enumerations are an implementation of the standard "Iterator" computing pattern. You can find a description of the pattern here on Wikipedia, and the standard Java Enumerations in the API (though this isn't used by ESRI, who have their own Enumerations for different data types). The standard code for dealing with enumerations is:

Enumeration e = (Enumeration) getSomething();
ThingEnumerated thing =;
while (thing != null) {
   // do stuff
   thing =;

or, using a for-each loop:

for (ThingEnumerated thing: (Enumeration)getSomething()) {
   // do stuff


In Arc, to get an enumeration of all Layers, we can use:

IEnumLayer enumLayer = map.getLayers(null,true);

In actually fact, the null can be replaced by a code encapsulated in an object that sets a filter, such that getLayers returns only layers of a specified type. The way described in the slides is slightly less efficient, but easier to understand. See the getLayers API docs for details. The list of codes isn't easy to find (link). Here are some you are likely to want:

IDataLayer {6CA416B1-E160-11D2-9F4E-00C04F6BC78E}

IGeoFeatureLayer {E156D7E5-22AF-11D3-9F99-00C04F6BC78E}

IGraphicsLayer {34B2EF81-F4AC-11D1-A245-080009B6F22B}

IFDOGraphicsLayer {34B2EF85-F4AC-11D1-A245-080009B6F22B}

ICoverageAnnotationLayer {0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E}

IGroupLayer {EDAD6644-1810-11D1-86AE-0000F8751720}

When we have a Layer, we can ask it for its geographical features, either as geographical features, or as rows in an attribute table.

Further info:

One of the best places to find code to do stuff is in the Examples gallery.

However, it is worth knowing that the APIs for other languages are similar to that for Java, and that they sometimes contain other details which are of use. In particular, the old C++ API and documentation can be useful.

Screenshot: A slide from the powerpoint

Getting data (powerpoint)

We may also want to sort or search for data.

Screenshot: A slide from the powerpoint

Search and Sort (powerpoint)

Further info:


For more on Queryfilters see this Arc webpage which also covers more details on sorting with searches.

[Key ideas from this part]