Download presentation
Presentation is loading. Please wait.
Published byPeregrine Lucas Modified over 9 years ago
1
Copyright © 2006 by Maribeth H. Price 6-1 Chapter 6 Queries
2
Copyright © 2006 by Maribeth H. Price 6-2 Outline Understanding queries and how they are used Knowing how to select features interactively using a variety of methods Selecting features using SQL queries on their attributes Selecting features based on their spatial location with respect to other features Using Definition Queries to create subsets of data layers
3
Copyright © 2006 by Maribeth H. Price 6-3 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
4
Copyright © 2006 by Maribeth H. Price 6-4 Selected features Highlighted in table Highlighted in map States for which POP2000>2 million
5
Copyright © 2006 by Maribeth H. Price 6-5 Types of Queries 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
6
Copyright © 2006 by Maribeth H. Price 6-6 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.
7
Copyright © 2006 by Maribeth H. Price 6-7 Selectable Layers States selectable All layers selectable
8
Copyright © 2006 by Maribeth H. Price 6-8 Selection options
9
Copyright © 2006 by Maribeth H. Price 6-9 Clear Selection On toolbar From table options menu From main menu
10
Copyright © 2006 by Maribeth H. Price 6-10 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
11
Copyright © 2006 by Maribeth H. Price 6-11 Selection logic No selection –All features exported No selected features –No features exported Selected features –Only selected features exported Example: Exporting features to a new shapefile
12
Copyright © 2006 by Maribeth H. Price 6-12 Two ways to select features Selecting by Attribute –Queries based on one or more fields in the table Find all wells with chloride concentration > 100ppm Selecting by Location –Queries based on the relationship of features to another layer Find all wells that lie inside industrial parcels
13
Copyright © 2006 by Maribeth H. Price 6-13 Select By Attribute Some Valid Queries SELECT *FROM cities WHERE "POP1990" >= 500000 SELECT *FROM counties WHERE “BEEFCOW_92” < “BEEFCOW_87” SELECT *FROM parcels WHERE “LU- CODE” = 42 AND “VALUE” > 50000 SELECT *FROM rentals WHERE “RENT” > 700 AND “RENT” < 1500 Note: Shapefile tables use quotes for field names; geodatabase tables use brackets
14
Copyright © 2006 by Maribeth H. Price 6-14 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
15
Copyright © 2006 by Maribeth H. Price 6-15 Boolean expressions A AND B A XOR BA NOT B A OR B A B 0 1 Blue circles represent areas where condition holds (True) = 1
16
Copyright © 2006 by Maribeth H. Price 6-16 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
17
Copyright © 2006 by Maribeth H. Price 6-17 Multiple conditions Use parentheses to enforce order of evaluation (“LU” = ‘RES’ or “LU” = ‘COM’) and “Value” > 100000 “LU” = ‘RES’ or (“LU” = ‘COM’ and “Value” > 100000) $75,000 $125,000 $75,000 $125,000 $75,000 $125,000 $75,000 $125,000 RESCOM
18
Copyright © 2006 by Maribeth H. Price 6-18 Select By Location Select counties that completely contain state capitals Select counties that are within 200 miles of Denver
19
Copyright © 2006 by Maribeth H. Price 6-19 Select By Location Select counties that intersect rivers Select rivers that intersect Texas
20
Copyright © 2006 by Maribeth H. Price 6-20 Select By Location Select cities that are within 20 miles of an interstate highway Select cities that are completely within counties named Washington
21
Copyright © 2006 by Maribeth H. Price 6-21 Selecting by location
22
Copyright © 2006 by Maribeth H. Price 6-22 Intersect
23
Copyright © 2006 by Maribeth H. Price 6-23 Within distance of
24
Copyright © 2006 by Maribeth H. Price 6-24 Using a selected set
25
Copyright © 2006 by Maribeth H. Price 6-25 Within the same layer
26
Copyright © 2006 by Maribeth H. Price 6-26 Selection methods Available for all three types of selection
27
Copyright © 2006 by Maribeth H. Price 6-27 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
28
Copyright © 2006 by Maribeth H. Price 6-28 Select from current Cities within 50mi of earthquakes Having > 500,000 people
29
Copyright © 2006 by Maribeth H. Price 6-29 Creating layers Common operation following a query Creates a layer file
30
Copyright © 2006 by Maribeth H. Price 6-30 Creating layers
31
Copyright © 2006 by Maribeth H. Price 6-31 Exporting selections Creates new shapefile
32
Copyright © 2006 by Maribeth H. Price 6-32 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.
33
Copyright © 2006 by Maribeth H. Price 6-33
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.