return to outline copyright © 2009 by maribeth h. price 4-1 chapter 4 attribute data

Post on 29-Jan-2016

220 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-1

Chapter 4

Attribute Data

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-2

Outline• GIS Concepts

– What is a table?– Queries on tables– Joining and relating tables– Summary statistics– Database storage concepts

• About ArcGIS– Working with tables in ArcGIS– Editing and calculating fields – Using Excel data with ArcGIS

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-3

What is a table?

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-4

Table terminology

TitleField

Records

Each field is specifically defined and established before any data can be

entered.

Field definitions control the type of data that can

be stored in a field.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-5

Types of tables

• Attribute table– Stores attributes of

map features– Associated with a

spatial data layer– Has special fields for

spatial information

• Standalone table– Stores any tabular data– Not associated with

spatial data– OID instead of FID

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-6

Database Management Systems

• Dedicated systems for managing tables of data

• Provide data management for agencies, universities, companies, etc.

• Designed for multi-user environments with enhanced security needs

• Focus on data tables with tools for queries, reporting, graphing, etc.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-7

Queries on tables

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-8

What is a query?

• A query extracts certain records from a table based on a specified condition– How many students have GPA > 3.5?– How many states have population > 1 million?– How many counties had greater population in

1990 than in 2000?– How many customers have last names

beginning with “Mac” or “Mc”?

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-9

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

4-10

SQL Query ExamplesSome 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

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

4-11

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

4-12

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

4-13

Query results

• The result of a query is a set of selected records that meet the criteria

• Subsequent operations on the table will use only the selected records and ignore the others. A user might…– Export the selected records to a new table– Calculate statistics on the selected records– Calculate new values for the selected records– Produce a report based on the selected

records

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-14

Joining and relating tables

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-15

Joining tables

Join tables on common field

Joined table

Destination table Source table

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-16

Join facts

• Joins are temporary relationships between tables used by a relational DBMS

• Tables must share a common field (key)

• Treats the two tables as a single table

• Original stored data is not affected

• Can be removed when no longer needed

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-17

One-to-one joins

When each record in the destination table matches exactly one record in the source table, we call it a cardinality of one-to-one.

Destination table (always imagine on the left)

Source table(always imagine on the right)

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-18

Types of Cardinality

• One-to-one– States to Governors– Husbands to wives

• One-to-many– States to cities– Districts to schools

• Many to one– Cities to states– Schools to districts

• Many-to-many– Students to classes– Stores to customers

In evaluating cardinality, always put the destination first.

(Destination on the left)

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-19

Rule of JoiningEach record in the destination table must match one and only one record in the source table.

One to one

Destination table Source table

Many to one

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-20

One to many

Destination table Source table

?

Violates the Rule of Joining

Record to join to destination is ambiguous

Must use a relate instead

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-21

Relates

• Similar to a join except that– The tables remain separate– Items selected in one table may be

highlighted in the related table

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-22

States: Select the New England States

Congress Reps of New England States

Related tables

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-23

Summary statistics

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-24

Statistics on a table field

Based on values in a field. Includes all records or a subset based on a query.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-25

Summarizing tables

• Calculate statistics for groups of features in a table• Groups by unique values in the one field• User chooses statistics to calculate for other fields• Produces another table as output with groups and stats

How many people live in each subregion?

What is the total area of each subregion?

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-26

Summarizing tables

How many earthquakes in each state?

Total deaths and damage in each state?

Average magnitude in each state?

Historic major earthquakes

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-27

How to summarize

Right-click State field

Sum Deaths

Sum Damage

Average Mag

Average MMI

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-28

Database storage concepts

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-29

Fields

• Fields have specific types available

• Must be defined before use

• Once defined, cannot be changed

• Naming rules– No more than 13 characters– Use only letters and numbers– Must start with a letter

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-30

Binary data

• Fundamental mode of computer storage• Data are stored as a series of 0’s and 1’s

representing numbers in base 2 (bits)• Bits are grouped by eight to form 1 byte. A

megabyte (MB) is 1 million bytes.

10011101

1 bit

one byte

In base 2:00000000 = 0 11111111 = 255

28 = 256

1111111111111111 = 65,565216 = 65,566

two bytes

01

1011

100101110111

1000100110101011

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-31

ASCII storage

• American Standard Code for Information Interchange (ASCII)

• Stores letters, characters, and symbols as single 7-bit binary codes

CAT = {67,65,84} decimal = 100001110000011010100

cat = {99,97,116} decimal = 110001111000011110100

148 = {49,52,56} decimal = 011000101101000111000

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-32

About ArcGIS

Chapter 4.

Attribute Data

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-33

Working with tables in ArcGIS

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-34

Tables in ArcGIS

• Tables contain attribute data

• Many formats, one interface

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-35

Sources of tables

• Dbase files

• INFO files

• ASCII Text files (tab or comma delimited)

• Records from SQL database systems

• Excel worksheets

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-36

ArcMap table interface

TitleField Right-click field

name to get menu

Records

Status bar Options menu

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-37

Adjusting field width

• Temporary, does not affect stored file

Hover over field break to get double arrow, then drag

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-38

Field properties tab

Field alias

Hide field

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-39

Shortcut to field properties

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-40

Formatting field display

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-41

Table appearance

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-42

Sorting tables

• Has no effect on original data

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-43

Select by Attributes

• Some valid queries

[POP1990] > 1000000

“STATE_NAME” = ‘Alabama’

[POP2000] >= [POP1990]

Note:

DBF tables have field names enclosed in quotes

Geodatabase tables have field names enclosed in brackets

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-44

Selecting records

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-45

Show selected

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-46

Clear SelectionOn toolbar

From table options menu From main menu

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-47

Field statistics

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-48

Statistics

• Statistics for fields are based on the selected records

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-49

ArcGIS field data types

Geodatabases and shapefiles

Short Integers stored as signed 2-byte binary numbers(value range from -32,000 to +32,000)

2551201

Long Integers stored as signed 4-byte binary numbers(value range from -2 billion to +2 billion)

156000

FloatFloating point values with 8 significant digits in

the mantissa1.2893851e12

DoubleDouble-precision floating point values with 16

significant digits in the mantissa1.111111111111

111e13

Text Alphanumeric strings ‘Maple St’

Date Date format 07/12/92

BLOBBinary large object; any complex binary data

including images, documents, etc.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-50

Field characteristics

• Length– The total characters a

text field can store

• Precision– The total width of

digits a numeric field can store

• Scale– The number of

decimal places

Length = 10Maple St.Maple Stre

1561985.128-1922.5600

0.0010.00001

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-51

Adding a new field

• In ArcCatalog layer properties

43

1

5

2

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-52

Adding a field• In ArcMap

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-53

Editing and calculating fields

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-54

Editing fieldsOpen Editor toolbar Start editing

Type edits in fields Save edits, stop editing

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-55

Calculating fields

Add a new field if necessaryConsider whether you need decimal places!

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-56

Calculate

Right-click field to calculate

Enter expression

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-57

Geodatabase geometry measures

• Automatically created and maintained– Usually appear at end of table

• Shape_Area field• Shape_Length field

– Units will match units of the coordinate system

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-58

Coverage geometry measures

– Automatically constructed– Updated whenever the BUILD or CLEAN

command is used to update topology• LENGTH field in arc tables• AREA field in polygon tables• PERIMETER field in polygon tables

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-59

Shapefile geometry measures

• Shapefiles DO NOT create or maintain these fields automatically!– Must be created and updated manually– Some functions and operations can change

the lengths and areas of features– If you find an AREA field there is no

guarantee that it is correct

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-60

Be careful!

Before After

AREA/LENGTH/PERIMETER fields in shapefiles are NOT automatically updated if features change.

Don’t use one of these fields unless you are CERTAIN that they are correct.

These area/perimeter fields are likely from a coverage

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-61

User geometry calculationsCreate field to hold values

Choose type, coordinate system, and units

Not automatically updated if features change!!!

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-62

Test yourself: True or False?

• A field named AREA in a shapefile will always have the correct area?– False. Shapefile area fields are not automatically

maintained.

• A field named AREA in a geodatabase will always have the correct area?– False. Automatically updated fields in a geodatabase

are called Shape_Area.

• A field named AREA in a coverage will always have the correct area?– True. Automatically updated area fields in a

coverage ARE called AREA.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-63

How to join or relate tables

To start, right-click the

destination table.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-64

Using Excel data with ArcGIS

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-65

Excel files

• Excel worksheets with suitable layout can be opened as tables in ArcGIS

• Most functions that do not involve changing the file will work (sort, query)

• Tables cannot be changed or edited

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-66

Excel file requirements

• First row must contain field headings with legal field names as defined earlier

• No blank rows or formulas should be used• Each column should contain only text or

only numbers.• It is helpful for each column to be

formatted as text, numeric, etc.• ArcMap cannot open files that are already

open in Excel—they must be closed first

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-67

Acceptable WorksheetCorrect field names

Columns formatted as text or numeric

No formulas or blank lines

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-68

Workbooks and worksheets

• An Excel workbook file (.xls) may contain more than one worksheet.

• By default there are three named Sheet1, Sheet2, Sheet3.

• There may be one or more named worksheets.

• ArcMap can only open one worksheet at a time.

• You will open the workbook like a folder and select a single worksheet

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-69

Adding a worksheet

1. Add data button2. Open workbook file like a folder

3. Add named worksheet, or the first unnamed worksheet.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-70

Excel file in ArcMap

You can use x-y locations in a table to produce points on a map.

But first you must know the coordinate system of these

locations. What is this one?

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-71

Add XY Data

You MUST use the Edit button to define the coordinate system.

Degrees indicate a geographic coordinate system (GCS). NAD83 is the most common in use today, but if you know it is something different you must use that.

Other tables might have units in UTM meters, State Plane feet, etc. You must know the coordinate system to create usable, correctly located points.

Return to Outline

Copyright © 2009 by Maribeth H. Price

4-72

Oregon climate stations

• Stations appear as points on the map, an “event layer”

• Export to shapefile or feature class to keep permanently

top related