1 / 13

Arc: Getting Layers

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.

shakti
Download Presentation

Arc: Getting Layers

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Arc: Getting Layers Dr Andy Evans

  2. 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.

  3. Getting data Document (.mxd file) Map AttributeTable Layer Feature 234 Values

  4. 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.

  5. Getting all Maps You can also get an Object containing all the Maps. IMaps maps = mxDoc.getMaps();

  6. 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].

  7. 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

  8. 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 }

  9. 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.

  10. 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.

  11. 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(); }

  12. 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.

  13. 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(); }

More Related