Return to Outline Copyright © 2009 by Maribeth H. Price 5-1 Chapter 5 Queries.

Slides:



Advertisements
Similar presentations
Week 1: Introduction to GIS
Advertisements

5-1 5 Tour of ArcMap and ArcCatalog ArcGIS for Assessors 1.
RGS-IBG Online CPD course in GIS Analysing Data in ArcGIS Session 6.
From portions of Chapter 8, 9, 10, &11. Real world is complex. GIS is used model reality. The GIS models then enable us to ask questions of the data by.
Data Storage and Processing GIS Topics and Applications.
Annotation & Nomenclature By Corey Fortezzo for PG&G GIS Workshop, 2010.
Return to Outline Copyright © 2009 by Maribeth H. Price 6-1 Chapter 6 Spatial Joins.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Technical Support: (989) GIS and Mapping Procedures in ArcMap 9.x Creating an ArcMap Project Editing an ArcMap Project Printing an ArcMap Project.
©2007 Austin Troy Lecture 7: Introduction to GIS 1.Queries and table operations for a single layer in ArcGIS 2.Intro to queries in Access Lecture by Austin.
©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.
©2005 Austin Troy Lecture 9: Introduction to GIS 1.Vector Geoprocessing Lecture by Austin Troy, University of Vermont.
@ 2007 Austin Troy. Geoprocessing Introduction to GIS Geoprocessing is the processing of geographic information. – Creating new polygon features through.
Intro. To GIS Lecture 6 Spatial Analysis April 8th, 2013
@ 2007 Austin Troy. Geoprocessing Introduction to GIS Geoprocessing is the processing of geographic information. Perform spatial analysis and modeling.
GIS Data Models Components of a GIS Map Common Data Models.
ArcGIS Overview Lecture 1: Software Layer characteristics Thematic maps.
Selecting and Displaying Features. Why do you need to select features? Why do you need to select features? Selection methods Selection methods Select.
Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p )
GIS UPDATE? Lecture 17 Lab 8: Music Festival, Part 2 – Spatial Analysis.
Preparing Data for Analysis and Analyzing Spatial Data/ Geoprocessing Class 11 GISG 110.
GIS Concepts ‣ What is a table? What is a table? ‣ Queries on tables Queries on tables ‣ Joining and relating tables Joining and relating tables ‣ Summary.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Microsoft Access Intro Class 5 Working with Queries.
Introduction to ArcGIS for Environmental Scientists Module 2 – Fundamentals Chapter 7 – Queries.
School of Geography FACULTY OF ENVIRONMENT Introduction to ArcToolbox and Geoprocessing.
Copyright © 2006 by Maribeth H. Price 2-1 Chapter 2 Working with ArcMap.
Copyright © 2006 by Maribeth H. Price 8-1 Chapter 8 Geoprocessing.
GIS 1 GIS Lecture 4 Geodatabases Copyright – Kristen S. Kurland, Carnegie Mellon University.
SESSION 3.1 This section covers using the query window in design view to create a query and sorting & filtering data while in a datasheet view. Microsoft.
Data Queries Selecting features in ArcMap Data queries  Important part of a GIS project Can be a part of your data preparation or final analysis  Data.
Copyright © 2006 by Maribeth H. Price 5-1 Chapter 5 Working with Tables.
Queries Select by Attribute Select by Location. What is a Query? A query extracts information from a data table for further use –Once extracted you can:
Map overlays & Geoprocessing Learn about spatial analysis functions overlays, clipping & buffering Use overlays to analyze multiple spatial criteria Understand.
Copyright © 2006 by Maribeth H. Price 6-1 Chapter 6 Queries.
Query and Reasoning. Types of Queries Most GIS queries will select spatial features Query by Attribute (Select by Attribute) –Structured Query Language.
Using the AccuGlobe Software with the IndianaMap Using the AccuGlobe Software.
NR 143 Study Overview: part 1 By Austin Troy University of Vermont Using GIS-- Introduction to GIS.
LBR & WS LAB 1: INTRODUCTION TO GIS.
©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.
School of Geography FACULTY OF ENVIRONMENT Querying with ArcGIS.
Return to Outline Copyright © 2009 by Maribeth H. Price 4-1 Chapter 4 Attribute Data.
Geographic Information Systems Applications in Natural Resource Management Chapter 5 Selecting Landscape Features Michael G. Wing & Pete Bettinger.
NSF DUE ; Wen M. Andrews J. Sargeant Reynolds Community College Richmond, Virginia.
Selecting features in ArcMap
Lecture 7 Basic GIS Analysis Operations
Copyright © 2006 by Maribeth H. Price 13-1 Chapter 13 Working with Geodatabases.
Introduction to Geographic Information Systems Fall 2013 (INF 385T-28620) Dr. David Arctur Research Fellow, Adjunct Faculty University of Texas at Austin.
2/18/ UT DallasPOEC 6382 Applied GIS Software 1 Data Management: Queries ArcPlot commands for selecting and summarizing data Meet certain conditions:
CENTENNIAL COLLEGE SCHOOL OF ENGINEERING & APPLIED SCIENCE VS 361 Introduction to GIS SPATIAL OPERATIONS COURSE NOTES 1.
Chapter 6. Attribute Data & Tables. Table terminology Title Field Records Each field is specifically defined and established before any data can be entered.
Chapter 8- Queries What are queries? Extract certain records from a map or table Records meet certain criteria –Aspatial queries All parcels with value.
CHAPTER 10 DATA EXPLORATION 10.1 Data Exploration Box 10.1 Data Visualization Descriptive Statistics Box 10.2 Descriptive Statistics Graphs.
Chapter 5 Queries.
GIS Institute Center for Geographic Analysis
Chapter 4 Attribute Data.
Attribute Extraction.
ArcMap: Geoprocessing
Attribute Extraction.
String several geoprocessing processes
Spatial Data Processing
Preliminaries: -- vector, raster, shapefiles, feature classes.
Location and Attribute Queries
Geospatial Database Create Geodatabase Practical Session
Mastering ArcGIS Chapter 7 Queries.
GIS Lecture: Geoprocessing
GIS Institute Center for Geographic Analysis
Vector Geoprocessing.
GIS Institute Center for Geographic Analysis
Presentation transcript:

Return to Outline Copyright © 2009 by Maribeth H. Price 5-1 Chapter 5 Queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-2 Outline GIS Concepts –About queriesAbout queries –Attribute queriesAttribute queries –Spatial queriesSpatial queries About ArcGIS –General information on queriesGeneral information on queries –Interactive selectionInteractive selection –Select By Attributes and Select By LocationSelect By Attributes and Select By Location –Selection methodsSelection methods –Creating layers from queriesCreating layers from queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-3 About queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-4 What are queries? Extract certain records from a map or table Records meet certain criteria –Aspatial queries All parcels with value greater than $100,000. –Spatial queries All parcels that lie completely within the flood plain

Return to Outline Copyright © 2009 by Maribeth H. Price 5-5 Selecting features of interest [COV_TYPE] = “TAA” Selecting aspen stands from a forest vegetation layer. Using statistics on areas (m 2 ) Minimum:12,900 Maximum:750,500 Sum:10,529,000

Return to Outline Copyright © 2009 by Maribeth H. Price 5-6 Exploring patterns Are aspen stands randomly scattered or clustered? Do they occur in particular portions of the forest? What are the distributions of stand densities?

Return to Outline Copyright © 2009 by Maribeth H. Price 5-7 Isolating for more analysis Are there any mature stands with large trees and open crowns? Where are they? [TREE_SZ96] = 'L' AND [DENSITY96] = 'A'

Return to Outline Copyright © 2009 by Maribeth H. Price 5-8 Exploring spatial relationships What fraction of stands are intersected by roads? What types of trees are adjacent to aspen stands?

Return to Outline Copyright © 2009 by Maribeth H. Price 5-9 Attribute queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-10 SQL Many databases use a special query language called Structured Query Language Can write queries that work in multiple DBMS environments Queries can be saved and reused Nearly always case-sensitive

Return to Outline Copyright © 2009 by Maribeth H. Price 5-11 SQL Query Examples Some Valid Queries SELECT *FROM cities WHERE "POP1990" >= SELECT *FROM counties WHERE “BEEFCOW_92” < “BEEFCOW_87” SELECT *FROM parcels WHERE “LU- CODE” = 42 AND “VALUE” > SELECT *FROM rentals WHERE “RENT” > 700 AND “RENT” < 1500 Programs may have an interface to help users build SQL expressions In most databases, SQL expressions are case-sensitive “Smith” ≠ “SMITH”

Return to Outline Copyright © 2009 by Maribeth H. Price 5-12 Queries as sets Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Queries are used to extract subsets (records) of interest from a set (table). Multiple criteria may be used (such as Geography majors from New York) T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-13 Single criteria Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Select students from T where [Home_State] = “NY” Select students from T where [Major] = “Geography” T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-14 Double criteria Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Select students from T where [Home_State] = “NY” OR [Home_State] = “NJ” Select students from T where [Home_State] = “NY” AND [Major] = “Geography” T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-15 AND vs OR? Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Select students from T where [Home_State] = “NY” OR [Home_State] = “NJ” Select students from T where [Home_State] = “NY” AND [Major] = “Geography” Each condition is tested separately. If AND is used, then BOTH must be true. If OR is used, then either may be true. T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-16 Boolean expressions A AND BA OR B A B AND and OR are known as Boolean operators. Boolean operators are used to evaluate pairs of conditions.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-17 AND vs OR? Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Select students from T where [Home_State] = “NY” AND [Major] = “Geography” A AND B A B T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-18 AND vs OR? Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] T A B C Select students from T where [Home_State] = “NY” OR [Major] = “Geography” A OR B A B

Return to Outline Copyright © 2009 by Maribeth H. Price 5-19 What do you get? Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Select students from T where [Major] = “Geography” AND [Major] = English” B AND C Select students from T where [Major] = “Geography” OR [Major] = “English” B OR C Select students from T where [State] = “NY” AND [Major] = “English” A AND C Select students from T where [State = “NY” OR [Major] = “English” A OR C T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-20 What do you get? Let T = [all students in University] Let A = [students from New York] Let B = [GPA > 3.0] Let C = [GPA < 2.0] Select students from T where [State] = “NY” AND [GPA] > 3.0 A AND B Select students from T where [State] = “NY” OR [GPA] > 3.0 A OR B Select students from T where [GPA] > 2.0 AND [GPA] < 3.0 ? AND ? Select students from T where [GPA] > 2.0 OR [GPA] < 3.0 ? OR ? T A B C

Return to Outline Copyright © 2009 by Maribeth H. Price 5-21 Other Boolean operators A AND B A XOR BA NOT B A OR B A B Some databases use additional operators besides AND and OR.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-22 What do you get? Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] A AND B A OR B A XOR B B XOR C A NOT B B NOT C T A B C A AND B A XOR BA NOT B A OR B A B B AND A B OR A B XOR A B XOR C B NOT A C NOT B

Return to Outline Copyright © 2009 by Maribeth H. Price 5-23 Test: AND vs OR “Land-use” = ‘RES’ AND “Land-use” = ‘COM’ “Land-use” = ‘RES’ OR “Land-use” = ‘COM’ “Pop2000” ≥ 5000 OR “Pop2000” < 9000 “Pop2000” ≥ 5000 AND “Pop2000” < 9000 Wrong Right Remember—you test each feature separately

Return to Outline Copyright © 2009 by Maribeth H. Price 5-24 Order of operations Boolean operators have equal order or precedence Evaluation occurs from left to right Parentheses must be used to change order

Return to Outline Copyright © 2009 by Maribeth H. Price 5-25 Multiple conditions Test using these parcels (“LU” = ‘RES’ or “LU” = ‘COM’) and “Value” > “LU” = ‘RES’ or (“LU” = ‘COM’ and “Value” > ) $75,000 $125,000 $75,000 $125,000 $75,000 $125,000 $75,000 $125,000 RESCOM

Return to Outline Copyright © 2009 by Maribeth H. Price 5-26 Searching for partial matches Sometimes you need to find one string within another rather than an exact match – Find all customer names beginning with “Mac” or “Mc” – Find all zip codes beginning with 0 Typically uses a “wildcard” character – *Mac* or *Mc* – 0*

Return to Outline Copyright © 2009 by Maribeth H. Price 5-27 The Like Operator “NAME” LIKE ‘%(D)%’ –Finds all of the (D) Democrats % is wildcard Ignores Don or Danforth “NAME” LIKE ‘%New %’ –Would find New Hampshire and New York, but not Newcastle or Kennewick

Return to Outline Copyright © 2009 by Maribeth H. Price 5-28 Spatial queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-29 Basic spatial relationships Intersection –Does the road cross the aspen? –Do two polygons share areas or boundaries? Containment –Is the aspen inside a geology unit? –Is a road inside a geology unit? Proximity –How many aspen stands within 200 meters of a road?

Return to Outline Copyright © 2009 by Maribeth H. Price 5-30 Spatial operators Spatial queries can employ a number of operators to test the basic conditions of intersection, containment, and proximity.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-31 The operators test relationships between two layers at a time. –The target layer is the one containing the features to be selected –The source layer is the one containing the features being compared to. Select the roads that are intersected by aspen stands. Select the aspen stands that are intersected by roads.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-32 Intersection operators Features intersect when any part of one feature touches, crosses, or overlaps another feature. The lower set includes “special cases” of intersecting features.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-33 Containment operators Features that enclose all of another feature contain it. Within is the inverse of contain

Return to Outline Copyright © 2009 by Maribeth H. Price 5-34 Types of containment Contains –One feature lies inside another and may share a boundary –Oregon contains Columbia county Completely contains –One feature lies inside another without touching the boundary –Oregon does not completely contain Columbia county, but does completely contain Jefferson county Columbia Jefferson Within is the inverse. Columbia county is within Oregon. Jefferson county is completely within Oregon.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-35 Proximity operators This operator tests whether the target features are within a specified distance of the source features. Volcanoes within 100 km of an interstate

Return to Outline Copyright © 2009 by Maribeth H. Price 5-36 About ArcGIS Chapter 5. Queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-37 General information about queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-38 Queries in ArcMap Interactive selection –Choose features by pointing to them on the screen Select By Attribute –Select features based on attribute criteria Select By Location –Select features based on their spatial relationships

Return to Outline Copyright © 2009 by Maribeth H. Price 5-39 Selection tools Selection menuTable of Contents Selection tab

Return to Outline Copyright © 2009 by Maribeth H. Price 5-40 The Selection tab Right-click entry for context menu You can also make layers selectable here by checking them This one clears features only for this layer

Return to Outline Copyright © 2009 by Maribeth H. Price 5-41 Viewing selected features Highlighted in table Highlighted in map States for which POP2000>2 million

Return to Outline Copyright © 2009 by Maribeth H. Price 5-42 Selection states No selection –All features exported No selected features –No features exported Selected features –Only selected features exported Example: Exporting features to a new shapefile

Return to Outline Copyright © 2009 by Maribeth H. Price 5-43 Clear Selection On toolbar From table options menu From main menu

Return to Outline Copyright © 2009 by Maribeth H. Price 5-44 Interactive selection

Return to Outline Copyright © 2009 by Maribeth H. Price 5-45 Interactive Selection Select Features tool Click on feature to select Hold down shift key to select more than one feature Draw a rectangle that passes through features to be selected.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-46 Selectable Layers States selectable All layers selectable

Return to Outline Copyright © 2009 by Maribeth H. Price 5-47 Select by Graphics Use Drawing toolbar to create graphic Then Select by Graphics

Return to Outline Copyright © 2009 by Maribeth H. Price 5-48 Select by Attributes Select by Location

Return to Outline Copyright © 2009 by Maribeth H. Price 5-49 Select By Attributes Some Valid Queries SELECT *FROM cities WHERE "POP1990" >= SELECT *FROM counties WHERE “BEEFCOW_92” < “BEEFCOW_87” SELECT *FROM parcels WHERE “LU- CODE” = 42 AND “VALUE” > SELECT *FROM rentals WHERE “RENT” > 700 AND “RENT” < 1500 Note: Shapefile tables use quotes for field names; geodatabase tables use brackets

Return to Outline Copyright © 2009 by Maribeth H. Price 5-50 Select by Location Target layer Source layer Spatial operator

Return to Outline Copyright © 2009 by Maribeth H. Price 5-51 Intersect

Return to Outline Copyright © 2009 by Maribeth H. Price 5-52 Within distance of

Return to Outline Copyright © 2009 by Maribeth H. Price 5-53 Using a selected set

Return to Outline Copyright © 2009 by Maribeth H. Price 5-54 Within the same layer

Return to Outline Copyright © 2009 by Maribeth H. Price 5-55 Selection methods

Return to Outline Copyright © 2009 by Maribeth H. Price 5-56 Selection methods Available for all three types of selection

Return to Outline Copyright © 2009 by Maribeth H. Price 5-57 The Boolean Two-Step Applying selection methods facilitates using multiple steps to apply multiple criteria—like using Boolean operators. OR NOT AND T A B C A OR BCreate new selection A; Add B to current selection A AND BCreate new selection A; Select B from current selection A NOT BCreate new selection A; Remove B from current selection

Return to Outline Copyright © 2009 by Maribeth H. Price 5-58 Applying selection methods Create new selection: hearts = yellow Add to current selection: hearts = red Add to current selection: hearts = blue Remove from selection: hearts = red Select from selection: hearts = blue Select from selection: hearts = orange

Return to Outline Copyright © 2009 by Maribeth H. Price 5-59 Combining queries Cities within 50mi of earthquakes Cities with population > 500,000 FEMA problem Distribute funding to quake- prone cities with large populations Both a spatial condition and an attribute condition Must be performed in sequence, although order doesn’t matter This is an AND operation.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-60 Spatial query Cities within 50mi of earthquakes

Return to Outline Copyright © 2009 by Maribeth H. Price 5-61 Attribute query Cities within 50mi of earthquakes Having > 500,000 people

Return to Outline Copyright © 2009 by Maribeth H. Price 5-62 Creating layers from queries

Return to Outline Copyright © 2009 by Maribeth H. Price 5-63 Creating layers Common operation following a query Creates a new layer with only the selected features Note that the new layer still refers to the original feature class with all the features. But it appears to contain only the selected features.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-64 Layers based on selections Still based on one original file shared by both layers Shows only a selected subset in the map and in the table Use as input for a tool, e.g. buffer only the aspen stands [cover_type] = ‘Aspen’ It’s smart to rename this so you can remember what it is.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-65 Creating layers

Return to Outline Copyright © 2009 by Maribeth H. Price 5-66 Exporting selections Creates new feature class

Return to Outline Copyright © 2009 by Maribeth H. Price 5-67 Definition Queries Redefine a layer to include a subset of the actual features Only selected features appear on map and in table Has no effect on data stored on disk Temporarily treats a layer as being smaller than it actually is Does not require an additional data set to be stored.

Return to Outline Copyright © 2009 by Maribeth H. Price 5-68