Programming for Geographical Information Analysis: Advanced Skills Lecture 3: Arc Data Framework Dr Andy Evans.

Slides:



Advertisements
Similar presentations
Week 1: Introduction to GIS
Advertisements

Why not just use Arrays? Java ArrayLists.
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Programming for Geographical Information Analysis: Advanced Skills Lecture 2: ArcObjects Framework Dr Andy Evans.
Labeling and Annotation
Advanced Databases: Lecture 2 Query Optimization (I) 1 Query Optimization (introduction to query processing) Advanced Databases By Dr. Akhtar Ali.
© The McGraw-Hill Companies, 2006 Chapter 17 The Java Collections Framework.
©2007 Austin Troy Lecture 7: Introduction to GIS 1.Queries and table operations for a single layer in Arc GIS 2.Intro to queries in Access Lecture by Austin.
ArcView Documents Francisco Olivera, Ph.D., P.E. Department of Civil Engineering Texas A&M University.
Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
Chapter 10 2D Arrays Collection Classes. Topics Arrays with more than one dimension Java Collections API ArrayList Map.
CSE 143 Lecture 7 Sets and Maps reading: ; 13.2 slides created by Marty Stepp
CST JavaScript Validating Form Data with JavaScript.
Introduction to ArcGIS for Environmental Scientists Module 2 – Fundamentals Lecture 6 – Table Functions.
ArcGIS Overview Lecture 1: Software Layer characteristics Thematic maps.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
(c) University of Washingtonhashing-1 CSC 143 Java Hashing Set Implementation via Hashing.
Programming for Geographical Information Analysis: Advanced Skills Lecture 4: Arc Data Editing Addin Programming Dr Andy Evans.
CPSC 203 Introduction to Computers T59 & T64 By Jie (Jeff) Gao.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2011 See online syllabus (also available through BlueLine): Course goals:
A New Generation GIS for the Classroom ArcGIS 9.0 A New Generation GIS for the Classroom.
Attributes in ArcGIS. ArcGIS Attributes FID – ESRI’s internal identifier Shape – Actual spatial data.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
Chapter 8: Arrays.
Advanced Databases: Lecture 6 Query Optimization (I) 1 Introduction to query processing + Implementing Relational Algebra Advanced Databases By Dr. Akhtar.
Arc: Accessing the Framework Dr Andy Evans. Code The code that goes in the addIn is then code to work with the ArcObjects framework. Ask App for Document.
Adding shapefiles as feature layers Adding coverages as feature layers Adding grids as raster layers Adding tables as table windows Adding text files as.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
ATN GIS Support ArcGIS: ArcCatalog.
Linked List. Iterators Operation to find a link, deleting, and inserting before or after a specified link, also involve searching through the list to.
1 Module 1 Highlights Learning your way around. 2 Course Stuff… There are now 45 of you! So I have to change some things 1.Each week when you hand in.
Objectives At the end of the class, students are expected to be able to do the following: Understand the searching technique concept and the purpose of.
ArcGIS: ArcCatalog. Agenda The ArcCatalog Interface General ArcCatalog ▫Navigating directories ▫Preview data ▫View metadata Advanced ArcCatalog ▫Modifying.
Arc: Events Dr Andy Evans. Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components.
©2007 Austin Troy Lecture 7: Introduction to GIS 1.Queries and table operations for a single layer in Arc GIS 2.Intro to queries in Access Lecture by Austin.
Project 5 : programming ArcObject with VBA Part I Vector data Sherry Fu CE 697V Nov. 30, 2006.
Introduction to KE EMu
Excel 2007 Part (3) Dr. Susan Al Naqshbandi
GoodOO Programming Practice in Java © Allan C. Milne v
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
NSF DUE ; Wen M. Andrews J. Sargeant Reynolds Community College Richmond, Virginia.
Chapter 11 Navigating Object Model Diagrams Week 6, 2008 Spring.
CPSC 203 Introduction to Computers T97 By Jie (Jeff) Gao.
CPSC 203 Introduction to Computers Lab 66 By Jie Gao.
05/02/ Records. 205/02/2016 Learning Objectives State: The difference between records and arrays. The difference between records and arrays. How.
CPSC 203 Introduction to Computers Lab 21 By Jie Gao.
NR 322: Editing Attributes Jim Graham Fall 2008 Chapter 6.
Arrays What is an array… –A data structure that holds a set of homogenous elements (of the same type) –Associate a set of numbers with a single variable.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
Arc: Editing Data Dr Andy Evans. Editing Data Putting Arc into an editing session. Adding a new field/column. Changing a value.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Part 1: Composition, Aggregation, and Delegation Part 2: Iterator COMP 401 Fall 2014 Lecture 10 9/18/2014.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
Introduction to GIS Programming Final Project Submitted by Todd Lenkin Geography 375 Spring of 2011 American River College.
Creating LOVs and Editors
Development of Linear Measure Tool using Application Framework
Hazards Planning and Risk Management INTRODUCTION TO ARCGIS
Cookies BIS1523 – Lecture 23.
Road Map CS Concepts Data Structures Java Language Java Collections
CS313D: Advanced Programming Language
Arrays An Array is an ordered collection of variables
Fall 2018 CISC124 12/3/2018 CISC124 or talk to your grader with questions about assignment grading. Fall 2018 CISC124 - Prof. McLeod Prof. Alan McLeod.
Coding Concepts (Data- Types)
Arc: Getting Layers Dr Andy Evans.
Introduction to Data Structure
Indexes and more Table Creation
ESRM 250/CFR 520 Autumn 2009 Phil Hurvitz
CMPE212 – Reminders Assignment 2 due next Friday.
Presentation transcript:

Programming for Geographical Information Analysis: Advanced Skills Lecture 3: Arc Data Framework Dr Andy Evans

Data Getting maps and layers Getting data points and attributes Sorting and searching

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.

Data Getting maps and layers Getting data points and attributes Sorting and searching

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

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.*; IMxDocument mxDocument = (IMxDocument)app.getDocument(); IMap mxDoc = mxDocument.getFocusMap(); FocusMap is the one visible in data view or selected in layout view.

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

IMaps You can loop through all the IMap Interface objects in an IMaps Interface object using its.getCount and.getItem methods. 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 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 Feature Layer FIDData AttributeTable 234 Values

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 Objects containing lists of other objects. Like a 1D array. Arc uses them to return arrays of data to you. Have a next method to get the next object. Also a reset method 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 IEnumSomething enumSomething = someEnumGettingMethod(); enumSomething.reset(); SomeClass variable = 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 Get an Enumeration of Layers IEnumLayer enumLayer = map.getLayers(null,true); enumLayer.reset(); ILayer layer = enumLayer.next(); while (layer != null) { \\ Do something with the ILayer layer = enumLayer.next(); }

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 You can check whether an object implements an Interface using Java’s instanceof keyword. 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. IGeoFeatureLayer featLayer = null; ILayer layer = enumLayer.next(); while (layer != null) { if (layer instanceof IGeoFeatureLayer) { featLayer = (IGeoFeatureLayer) layer; //Do something with featLayer } layer = enumLayer.next(); }

Data Getting maps and layers Getting data points and attributes Sorting and searching

Getting Data/Features from Layers Assign your Layer to an appropriate Interface. IGeoFeatureLayer : Treat as geographical data IFeatureLayer : Treat as a general Layer IAttributeTable : Treat as an attribute table Get the Attribute Table or search the Layer.

Getting data Once we have our Layer, we want to get data from it. Map Feature Layer FIDData AttributeTable 234 Values

Getting the Attribute Table Assuming we have a Layer Enumeration, we set the Layer to an IAttributeTable. import com.esri.arcgis.geodatabase.*; IAttributeTable pAttributeTable = (IAttributeTable)enumLayer.next(); ITable table = pAttributeTable.getAttributeTable(); IRow row = null; for (int i = 1; i <= table.rowCount(null); i++) { row = table.getRow(i); int index = table.findField("School"); Object value = row.getValue(index); }

Getting the Attribute Table Get Layer as AttributeTable Get actual Table Get each row Get a particular Field IAttributeTable pAttributeTable = (IAttributeTable) enumLayer.next(); ITable table = pAttributeTable.getAttributeTable(); IRow row = null; for (int i = 1; i <= table.rowCount(null) ; i++) { row = table.getRow(i); int index = table.findField("School"); Object value = row.getValue(index); }

Getting data Alternative is to get data from a Feature. Map Feature Layer FIDData AttributeTable 234 Values First though, we need to get only the features we are interested in. We can search for these.

Data Getting maps and layers Getting data points and attributes Sorting and searching

Searching You need to get a reference to the data and a search cursor ( ICursor / IFeatureCursor ). The search cursor jumps between records in a dataset that match some search criteria. The cursor marks the row/feature in the dataset that you’re currently interested in. They have a nextSomething method which gets a object appropriate to the dataset.

Search Methods IFeatureLayer / IGeoFeatureLayer IFeatureCursor cursor = featureLayer.search (queryFilter, false); ITable from an IAttributeTable ICursor cursor = table.search (queryFilter, false); Where queryFilter is an IQueryFilter Object True / false determines how the records are allocated to the Cursor – set to False.

You can get everything by setting these to null. cursor = pFeatureLayer.search(null, false); IQueryFilter objects store fields you want returned and query strings. You need to (rare this) make a QueryFilter object from scratch… IQueryFilter queryFilter = new QueryFilter(); Making a QueryFilter

IQueryFilter Objects pQueryFilter.setSubFields("SCHOOL,CITY"); pQueryFilter.addField ("POSTCODE"); pQueryFilter.setWhereClause = "CITY = 'Leeds'"; By default the fields are set to “*” i.e. all fields, so if you use just addField you’ll have to setSubFields to “” first.

Sorting data You can use searching to also sort data. However, it is a bit hit-and-miss. We’ll look at the more usual TableSort in the practical.

Getting Data from a Feature Use the cursor to get the next feature IFeature feature = featureCursor.nextFeature(); while (feature != null) { //Do stuff to feature feature = featureCursor.nextFeature(); } The Feature method getValue(i) takes in an integer number equalling the position of the field column. If you don’t know it, there are lookup methods that return integers… feature.getFields().findField("SCHOOL");

Setting/Getting Features Selected An alternative is to get the selected Features. To get the Features you need IMap’s getFeatureSelection method, or an ISelectionSet Object. IMap’s selectFeature method takes in an ILayer and IFeature. Refresh the display using the MxDocument’s refresh. mxDoc.getActiveView().refresh();

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

Summary Get the Application’s Document. Get the Maps from it. Pick the one you want or loop through them. Get a Layer from the Map, or Loop through all of them. Generate an Attribute table and use Rows / Fields to get data. Or use the Layer’s search routine to search for Features.

Next Lecture Editing data. External applications. Practical Building a Toolbar. Getting and sorting data.