Queries (ppt)

Download Report

Transcript Queries (ppt)

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:
• Print, calculate stats, edit, graph, save as a new
layer, do more queries
• Queries come in two different flavors:
– Attribute queries
– Spatial queries
ArcGIS Selection methods
• ArcGIS has three methods for selecting
features
– Interactive Selection
– Select by Attributes
– Select by Location
Interactive Selection
•This feature allows
use of the select
feature tool and the
manual selection of
features in a table or
map
•You can also use a
graphic to select
features (i.e.: box,
line, circle, etc.
Interactive Selection
Select Features tool
Hold down shift key to
select more than one
feature
Draw a rectangle that
passes through features
to be selected.
Click on feature to select
Copyright © 2006 by Maribeth H.
Price
6-5
Selectable Layers
All layers selectable
Copyright © 2006 by Maribeth H.
Price
6-6
States selectable
Selection
options
Copyright © 2006 by Maribeth H.
Price
6-7
Clear Selection
On toolbar
From main menu
From table options menu
Copyright © 2006 by Maribeth H.
Price
6-8
Selection by Attributes
•The user specifies criteria
based on fields in the
attribute table
–This involves an
expression using Structured
Query Language (SQL)
•Expressions are written
using the fields buttons
accessed in the Select By
Attributes window
–SELECT *FROM and
WHERE keywords are
present to help spell out the
query
AND vs OR
Remember—you test each feature separately
Right
Wrong
“Land-use” = ‘RES’
AND
“Land-use” = ‘COM’
“Land-use” = ‘RES’
OR
“Land-use” = ‘COM’
“Pop2000” ≥ 5000
OR
“Pop2000” < 9000
“Pop2000” ≥ 5000
AND
“Pop2000” < 9000
Copyright © 2006 by Maribeth H.
Price
6-10
Use of Boolean Operators
SELECT *FROM accounts WHERE “Cust” = ‘COM’ AND
“Balance” > 500
SELECT *FROM accounts WHERE “Cust” = ‘COM’ OR
“Cust” = ‘GOV’
SELECT *FROM accounts WHERE [BALANCE] > 500 AND
[BALANCE] <1500
SELECT *FROM parcels WHERE (“LUCODE” = 42 AND
“VALUE” > 50000) OR “SIZE” > 50
SELECT *FROM parcels WHERE “LUCODE” = 42 AND
(“VALUE” > 50000 OR “SIZE” > 50)
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
$75,000
$75,000
$125,000
$125,000
$125,000
RES
Copyright © 2006 by Maribeth H.
Price
$75,000
COM
6-12
$125,000
Selection by Location
• This powerful feature allows selections
based on spatial features
– Two layers are used for the selection, i.e.:
the number of homes in a flood plain
• Select By Location allows many
different options:
– Intersect, contain, identical to, have their
center in, are completely within, etc.
Select By Location
Select counties that completely
contain state capitals
Copyright © 2006 by Maribeth H.
Price
Select counties that are within
200 miles of Denver
6-14
Select By Location
Select counties that intersect
rivers
Copyright © 2006 by Maribeth H.
Price
Select rivers that intersect Texas
6-15
Select By Location
Select cities that are within 20
miles of an interstate highway
Copyright © 2006 by Maribeth H.
Price
Select cities that are completely
within counties named Washington
6-16
Selecting by location
Copyright © 2006 by Maribeth H.
Price
6-17
Intersect
Copyright © 2006 by Maribeth H.
6-18
Within distance of
Copyright © 2006 by Maribeth H.
Price
6-19
Creating layers
• Common operation following a query
• Creates a layer file
Copyright © 2006 by Maribeth H.
Price
6-20
Creating layers
Copyright © 2006 by Maribeth H.
Price
6-21
Exporting selections
Creates new
shapefile
Copyright © 2006 by Maribeth H.
6-22
Choosing the Selection Method
• ArcMap has four possible methods for
the selection of features
– Create new selection
– Add to current Selection
– Remove from current selection
– Select from current selection