arc getting layers n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Arc: Getting Layers PowerPoint Presentation
Download Presentation
Arc: Getting Layers

Loading in 2 Seconds...

play fullscreen
1 / 13

Arc: Getting Layers - PowerPoint PPT Presentation


  • 99 Views
  • Uploaded on

Arc: Getting Layers. Dr Andy Evans. ArcMap IMXDocument methods. Used for getting data: getActiveView() i.e. layout view or data view data. getFocusMap() i.e. currently selected/shown map. getMaps() i.e. all maps. getSelectedItem() i.e. that the user has picked.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Arc: Getting Layers' - shakti


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
arc getting layers

Arc: Getting Layers

Dr Andy Evans

arcmap imxdocument methods
ArcMap IMXDocument methods

Used for getting data:

getActiveView() i.e. layout view or data view data.

getFocusMap() i.e. currently selected/shown map.

getMaps() i.e. all maps.

getSelectedItem() i.e. that the user has picked.

getSelectedLayer() i.e. that the user has picked.

Documents also implement IDocument, the main use of which is programmatically controlling toolbars.

getting data
Getting data

Document

(.mxd file)

Map

AttributeTable

Layer

Feature

234

Values

getting a map
Getting a Map

A Map contains all the data and features in the Data View or each Layout View frame.

import com.esri.arcgis.carto.*;

IMxDocumentmxDocument = (IMxDocument)app.getDocument();

IMapmxDoc = mxDocument.getFocusMap();

FocusMap is the one visible in data view or selected in layout view.

getting all maps
Getting all Maps

You can also get an Object containing all the Maps.

IMaps maps = mxDoc.getMaps();

imaps
IMaps

You can loop through all the IMap Interface objects in an IMaps Interface object using its .getCountand .getItemmethods.

IMap map = null;

for (int i = 0; i < maps.getCount; i++) {

map = maps.getItem(i)

}

Other IMaps methods include…

add(IMap), create(), remove(IMap), removeAt(index), Reset [Remove all].

getting data1
Getting data

It’s rare we want to get data out of a Map. It’s more usual to get data from a Layer ~ (a Coverage, FeatureDataset, Image etc.).

Map

AttributeTable

Layer

Feature

234

Values

getting layers i
Getting Layers I

If you know what the type of the Layers are, you can get them thus…

// Assuming we've got a IMap object "map".

ILayer layer = null;

for (int i=0; i < map.getLayerCount(); i++) {

layer = map.getLayer(i);

// Do something

}

enumerations
Enumerations

Objects containing lists of other objects. Like a 1D array.

Arc uses them to return arrays of data to you.

Have a nextmethod to get the next object.

Also a resetmethod to return to the start.

ArcObject types have different Enumerations.

e.g. IEnumLayer is the Interface for a set of Layers.

standard use of enumerations
Standard use of Enumerations

IEnumSomethingenumSomething = someEnumGettingMethod();

enumSomething.reset();

SomeClassvariable = enumSomething.next();

while (variable != null) {

\\Do stuff with variable

variable = enumSomething.next();

}

Note we get the first variable first, then do something with it, before getting the next and checking whether it is null.

getting layers ii
Getting Layers II

Get an Enumeration of Layers

IEnumLayerenumLayer =

map.getLayers(null,true);

enumLayer.reset();

ILayer layer = enumLayer.next();

while (layer != null) {

\\ Do something with the ILayer

layer = enumLayer.next();

}

types of layer
Types of Layer

Remember however that we can add many things as Layers (images, data, etc.).

Main types:

IFeatureLayer

IGeoFeatureLayer

IGraphicsLayer

Others include more specific FeatureLayers, FDOGraphicsLayers (Annotation), TinLayer, RasterLayer, and CoverageAnnotationLayer.

If we don’t know the layers in the document we may need to check for a specific type.

the instanceof k eyword
The instanceof keyword

You can check whether an object implements an Interface using Java’sinstanceofkeyword.

For example, if the user’s selected something in ArcMap's tree of contents, you can test whether it’s a GeoFeatureLayer, thus…

// Assuming we’ve got an enumeration of Layers.

IGeoFeatureLayerfeatLayer = null;

ILayer layer = enumLayer.next();

while (layer != null) {

if (layerinstanceofIGeoFeatureLayer) {

featLayer= (IGeoFeatureLayer) layer;

//Do something with featLayer

}

layer = enumLayer.next();

}