39
Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307- 346)

Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Embed Size (px)

Citation preview

Page 1: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes & Queries

Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Page 2: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes

• To make decisions we need information about the spatial areas in Shapefiles:– Which parcels are big enough for my house?– Which areas have more poverty for development

funds?– Where environmental areas are threatened by

encroaching development?– How many endangered species are in each area?– How many fish are in each stream?– Who borders the streams we need to restore?– Which areas of the most fire fuels (dead wood)?

Page 3: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes

• To answer questions we need information:– Counts of species– Counts of people, animals, houses, etc.– Height of trees, buildings, etc.– Size and perimeter of areas– Length of streams, roads– Ownership of parcels

• These are held in attributes

Page 4: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Census Scope

• An organization making census information available

• http://www.censusscope.org• Check out the variety of maps, charts, and tables

they have made available from US census data. • These are computed using attributes of the

census data at a county level (i.e. a polygon layer of counties).

Page 5: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Queries and Calculations

• We also need to select (query) certain types of information:– People over 60 years old– Parcels over 1 acre– Areas with 1 or more endangered species

• And compute new values:– Number of animals per meter– Density of trees– Board feet per acre– Fish per meter

Page 6: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes, Queries, Calculations

• Attributes are associated with features – In the Attribute table

• Queries “Select” data – Available in “Select by Attribute”– Based on Structured Query Language (SQL)

• Calculations available in:– Geometry calculator– Field (column) calculator

Page 7: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes

• Table attached to each layer• Each row tied to a feature

– Point– Polyline(s)– Polygon(s)

• Each column (field) represents a different attribute and has:– Name– Type– Other properties

Page 8: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attribute Terminology

Attribute “Table”

Row or Record- One per feature

Column or Field

Feature, Object, or Record ID

Page 9: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attribute Terminology

• Esri borrows from four disciplines for labels for attributes

Spatial Data Spreadsheet Database OOP

Attribute Table Spreadsheet Table -

An attribute Column Field Property

Feature ID? Row Number Record ID Object ID

Attributes for one feature

Row Record Object’s properties

Attribute value Cell Entry Property Value

Filter Selection Query -

Page 10: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes

• Vector Attributes (very common)• Raster Attributes (when available)• Examples of attributes:

– Name– Population/Census numbers– Vegetation characteristics– Dates– Coordinates– Ownership– Park Type

Page 11: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Vector Attributes

• Used For:– Labels:

• Direct: Names of cities, states, etc.• Results of “expressions”: City with it’s population

– Symbology:• Size city by it’s population

– Selection• Select cities over a certain size

– Sub-setting• Create a new layer with cities over 1 million

Page 12: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Types of Attributes

• Qualitative– Nominal: No order, types

• Quantitative– Ordinal: Ordered set of classifications– Interval: Values along arbitrary scale– Ratio: Values along non-arbitrary scale– Cyclic: Values repeat

Page 13: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Types of Attributes (examples)

• Qualitative– Nominal: Land Cover Type

• Quantitative– Ordinal: Fire danger low, medium, high– Interval: Temperature– Ratio: Population Density (floating point)

• Number of People / Area– Cyclic: Directions (0 to 360 degrees)

Page 14: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Examples of Attributes

• Names• Taxonomic Identification:

– Scientific Names, common names, codes (NRCS codes)

• Organism characteristics• Population values• Distance, Area• Dates• Collector’s names• Coordinates

Page 15: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Structured Query Language (SQL)

• Comes from the database industry• “INSERT”, “DELETE”, and “SELECT” rows in

tables• Very rich syntax• Portions of “SELECT” grammar used heavily

in ArcGIS:– Selecting attributes– Raster calculator– Geodatabases

Page 16: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Select by Attributes

• SELECT * FROM TableName WHERE:– “WHERE Clause” or Filters

• Available from the Attribute Table

Page 17: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Attributes in ArcGIS

Page 18: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Filter Examples

• WHERE:– FID = 1– “Area” < 10000– “Area” <= 10000– “Name” = ‘Crater Lake’ (case dependent)– “Name” LIKE ‘Crater Lake’ (ignores case)

• Notice:– Fields have double quotes– String values have single quotes

Page 19: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

SQL Comparisons

• Equals: =• Greater than: >• Less than: <• Greater than or equal: >=• Less than or equal: <=• Not equal: <>• Like: case independent string comparison with

wild cards (%)

Page 20: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Boolean Values

• True = T = 1 • False = F = 0

Page 21: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Boolean Operators

A B A AND B A OR B NOT A NOT B

T T T T F F

T F F T F T

F T F T T F

F F F F T T

Page 22: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

More Complex Filter Examples

• WHERE:– “Name” LIKE ‘Hawaii’ AND Area < 10000– “Species” LIKE ‘Ponderosa’ AND DBH > 1

Page 23: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Select by Location

• Proximal• Topological

– Identical– Adjacent– Within– Share segment

Page 24: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Table Queries:The selection of a subset of features that meet some criteria.

“Area” > 20.0 “Landuse” = ‘Urban’ AND “Municip” = ‘City’

Expression: A sequence of operands and operators constructed according to the syntactic rules of a symbolic language (SQL)

Page 25: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Boolean Operators: Used to combine expressions

1) And

2) Or

3) Not

4) Xor

“AREA” > 10000 AND “IMPR” = 0

“RAINFALL” < 20 OR “SLOPE” > 35

NOT ("STATE_NAME" = ‘Colorado’)

[RAINFALL] > 20 XOR [SoilType] = ‘X’

Order matters:

(A AND B) OR C is not the same as

A AND (B OR C)

And – Must meet both criteriaOr – Can meet either criteria

Page 26: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Boolean Operators: Used to combine expressions

1) And

2) Or

3) Not

4) Xor

“AREA” > 10000 AND “IMPR” = 0

“RAINFALL” < 20 OR “SLOPE” > 35

NOT ("STATE_NAME" = ‘Colorado’)

[RAINFALL] > 20 XOR [SoilType] = ‘X’

Order matters:

(A AND B) OR C is not the same as

A AND (B OR C)

Operator Description

< less than

> greater than

<= less than or equal to

>= greater than or equal to

= Equal to

<> not equal to

Comparison Operators: Used to compare values

Page 27: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Two ways to combine tables:

JoinsUsed for 1-to-1 relationships, or many-to-1 relationships between attribute table and external table.

Relates Used for 1-to-many relationships, many-to-many relationships between attribute table and external table.

Page 28: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Table Join:Combines two tables based on the value of a field that can be found in both tables (a “common field”).

Parcel-ID Owner

2 John Smith

5 Bruce Martin

6 Anne Davis

1 Steve Arnold

8 Rick James

Parcel-ID Acres

2 2

5 1.5

6 6

1 3

8 1.6

Parcel-ID Acres Owner

2 2 John Smith

5 1.5 Bruce Martin

6 6 Anne Davis

1 3 Steve Arnold

8 1.6 Rick James

Table A Table B

Page 29: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Joins and Relates JoinJoins and Relates Join

A Join lets you join data from an external table to your attribute table based on the value of a field that can be found in both tables.

A Join lets you join data from an external table to your attribute table based on the value of a field that can be found in both tables.

Page 30: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

+

Attribute tableExternal Tabular File (immigration)

Example of 1:1 relationship

Page 31: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Results of Join OperationResults of Join Operation

Page 32: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Example of Many-to-1 relationshipExample of Many-to-1 relationship

Join

Page 33: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)
Page 34: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Example of 1-to-many relationship

Relate

Page 35: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Joins and Relates RelateJoins and Relates Relate

Page 36: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Options Related TablesOptions Related Tables

Page 37: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

Example of 1-to-many relationship

Relate

Page 38: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

SummarizeCreates a new table containing one record for each unique value occurring in a selected field along with statistics summarizing the data in any of the other fields.

Group together All records that have the same State name.Get summary stats on the values in the rain field.

Page 39: Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p. 307-346)

SummarizeSummarize

Find combined (total) area for each “covertype”

Summarize QuantitativeBy Qualitative!