Database Management: Tables

advertisement
Database Management: Tables
INFO and TABLES module
Getting Attribute Data into Arc/INFO
Modifying Feature Attribute Tables in Tables or INFO
Inputting from and Outputting to External Files
Modifying Feature Attribute Tables in Arc and ArcPlot
Join and Relate tabular data
1
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Intro to Tabular Database Management
• The information which describes and quantifies spatial features in the
ARC/INFO GIS is stored in INFO files and, optionally, in external
database management system (DBMS) tables.
• INFO is a totally stand alone relational database management system
exclusively dedicated to Arc/INFO.
• Each ARC/INFO module (Arc, ArcEdit, ArcPlot, Tables, INFO)
provides some tools for managing and changing these tables
• There are two types of attribute tables: feature attribute tables and
related tables.
– Feature attribute tables are generated by the ARC/INFO software when
you create a feature class topology, and must be in INFO file format
(discussed in depth in first lecture);
– Related attribute tables can be either INFO files or external DBMS tables.
2
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Review: Feature Attribute Tables
•
Types of feature attribute tables:
– Points - Point attribute table - PAT
– Arcs - Arc attribute table - AAT
– Polygons - Polygon attribute table - PAT
Each contain both internally generated topological data plus user defined
attributes -- See Introductory lecture for data stored in each
• To look at data variables (items) in a feature attribute table:
– Arc: items <cover>.pat or Arc: items <cover>.aat
– Arcplot: items <cover> <feature_class>
– Info or Tables: items (after having selected the feature attrib table)
• To look at data stored in each item
– Arc: list <cover>.pat or Arc: list <cover>.aat
– Arcplot: list <cover> <feature_class>
– Info or Tables: list (after having selected the feature attrib table)
Be sure to note difference in usage for ITEMS and LIST
between Arc and ArcPlot!!!!
3
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Sample Item Definitions
• Example:
Arc: items pub.pat
COLUMN
1
5
9
13
17
25
50
65
ITEM NAME
AREA
PERIMETER
PUB#
PUB-ID
ID
NAME
ADDRESS
CITY
WIDTH OUTPUT TYPE N.DEC
4
12
F
3
4
12
F
3
4
5
B
4
5
B
8
12
F
0
25
25
C
15
15
C
12
12
C
-
• There are 8 items (variables). The first 4 are standard, crated by Info. The
last 4 are user created.
4
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Understanding Item Definitions
• An item (column) is described in terms of four variables:
– name - the name of the item, up to 16 characters in length
• e.g. cover-id, landuse, pop97, etc.
– type - the data types used to store values
•
•
•
•
•
•
I - integer (one byte per digit)
B - binary integer (requires less storage than I types)
C - character
N - floating point (e.g. decimal) number stored as one byte per digit
F - floating point binary number
D - date (e.g. yyyymmdd)
– width - the width of the item in bytes required for storage
• I - 1-16 bytes
B - either 2 or 4 bytes
• C - 1 to 320 characters
N - 1 to 16 digits
• F - 4 for single, 8 for double precision D - always 8 bytes
For F or N also provide the number of decimal places for real numbers
– Output width - the width of item values when displayed
5
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
How do you know which item types to specify?
• If the attribute values contain any non-numeric characters, you must
specify type C.
• If the values are numeric with a decimal place, you must use N or F.
Storing numeric values as F (floating point binary) allows you to store
large numbers in a small amount of space (4 bytes).
• If the values are numeric with no decimal, store them as I or B. Again,
using B (binary) saves storage space.
• You can store numeric values as characters but you can’t manipulate
characters arithmetically.
How do you know how much space to specify?
• Define the item width for types C, I or N to accommodate the longest
value to be stored; unnecessarily long widths waste storage space.
• Output width should be sufficient to display the longest character
string or numeric value. Always include one space for the decimal and
one for negative sign.
6
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
List
•
To look at data stored
Arc: list lulcsp.pat
1
AREA
PERIMETER
LULCSP#
LULCSP-ID
LULC_CODE
LEVEL_I
LEVEL_II
2
AREA
PERIMETER
LULCSP#
LULCSP-ID
LULC_CODE
LEVEL_I
LEVEL_II
= ************
= 26829452.50
= 1
=
0
= 0
=
=
=12154654112
= 3137822.500
= 2
=
21
= 21
= AGRICULTURAL LAND
= CROPLAND/PASTURE
3
AREA
PERIMETER
LULCSP#
LULCSP-ID
LULC_CODE
Continue?
LEVEL_I
LEVEL_II
4
AREA
PERIMETER
LULCSP#
LULCSP-ID
LULC_CODE
LEVEL_I
LEVEL_II
5
AREA
PERIMETER
LULCSP#
LULCSP-ID
LULC_CODE
LEVEL_I
LEVEL_II
= 11278215.000
= 17881.912
= 3
=
41
= 41
= FOREST LAND
= DECIDUOUS FOREST
= 2316684.250
= 6632.658
= 4
=
11
= 11
= URBAN OR BUILT-UP
= RESIDENTIAL
= 7348584.000
= 12674.189
= 5
=
41
= 41
= FOREST LAND
= DECIDUOUS FOREST
7
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Reminder: File Structure
• The INFO directory for a coverage is at the same directory level as the
coverage.
• All coverages have several INFO files, the most common of which are
the feature attribute tables (.pat or .aat).
• The coverage to which info files correspond is not apparent, therefore:
– Always use Arc: copy to copy coverages to another directory. Never use
your operating system to copy coverages
– Always use Arc: copyinfo to copy INFO files which are not associated
with a coverage. Again, these files are not identifiable with your
operating system. To find their names use: Arc: dir info, or use dir in
Tables or INFO
• However, you may also use or generate text files outside of the INFO
database. You will only be able to see these (and copy or delete them)
using your operating system (e.g. with Windows Explorer)
8
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Sample Data Management Commands
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
COMMAND
MODULES (usage will differ)
ITEMS
LIST
RESELECT
ADDITEM
DROPITEM
JOINITEM
CALCULATE
MOVEITEM
RELATE (series)
SELECT
DIR
DEFINE, ERASE
MOVE
ADD, ADD FROM
UPDATE
ALTER, MODIFY
REDEFINE
KILL
GET, OUTPUT, PRINT
COPYINFO
KILLINFO
Arc, ArcPlot, ArcEdit, Tables, INFO
Arc, ArcPlot, ArcEdit, Tables, INFO
Arc, ArcPlot, ArcEdit, Tables, INFO
Arc, ArcEdit, Tables
Arc, ArcEdit, Tables
Arc, ArcEdit, Tables
ArcPlot, ArcEdit, Tables, INFO
ArcPlot, ArcEdit (use MOVE in tables, info)
Arc, ArcPlot, ArcEdit, Tables
ArcEdit, Tables, INFO
Tables, INFO
Tables, INFO
Tables, INFO (use moveitem in arcplot, arcedit)
Tables, INFO
Tables, INFO
Always remember,
Tables, INFO
Tables, INFO
check usage since
Tables, INFO
can differ between
Tables, INFO
modules!
Arc
Arc
9
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
it
INFO and TABLES
•
INFO and TABLES are two programs supplied with Arc/INFO for managing
attributes.
– INFO is the main relational database management system for Arc/INFO.
– TABLES also provides table management with a subset of INFO functions.
TABLES provides all the functionality needed for most database management
tasks, and is a little easier to get into and out of and is less case sensitive than
INFO.
•
INFO is case sensitive and requires all parameters, data set names and variable
(item) names to be typed in UPPERCASE
– Also, you are first prompted for “username”: specify ARC
•
•
•
No usage help available at the INFO prompt. Can enter “help” and the
command name, and get none-GUI help, or access ArcDoc from NT Programs
menu.
Both TABLES and INFO access the same data files.
Cannot use aml’s or watch files in Tables or INFO
Conclusion: generally use TABLES
Do not forget, some table management and change is also done from Arc and
ArcEdit
10
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Comparison of Tables to Info
• INFO
• TABLES
–
–
–
–
–
–
–
–
–
Create New Files
Add data
Display data
Extract data
Manipulate data
Stack relate files (ARC relate)
Create items
Redefine items
Limited changes to item
definitions
– Undo changes
– Use with AML transparently
–
–
–
–
–
–
–
–
–
–
–
–
–
Create New Files
Add data
Display data
Extract data
Manipulate data
Stack relate files (INFO relate)
Create items
Redefine items
Limited changes to item
definitions
Use with AML through &data
block
Write reports
Program
Input forms for data entry
11
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Listing INFO File names
• Files in INFO cannot be seen by name in your NT Explorer Window -they reside within the INFO folder with an internally generated name
(e.g. arc0003.dat and arc0003.nit).
• You can list all INFO file names by using the DIR INFO command in
Arc,
Arc: dir info
• in INFO or in TABLES this is abbreviated to just DIR.
Tables: dir
• Be clear on the difference between dir info and lc (listcoverages)
– lc simple names the coverages in your workspace
– Dir info names all the INFO files in your work space including those
associated with a coverage
– There are normally at least 3 INFO files associated with each coverage:
.pat and/or .aat, .bnd, .tic
12
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Internal and External INFO Tables
• INFO files can be internal or external. The terms refer to where the
data are physically stored on your computer system.
– INTERNAL FILES:
• Data located in a data file internal to the INFO directory:
arcxxxx.dat contains the actual data
• Examples of Internal files
– lookup tables
– data files from somewhere else, not topologically linked to a coverage, but they
have been converted from original format into INFO file format
– EXTERNAL FILES
• Data located in a data file external to the INFO directory:
arcxxxx.dat contains a pointer to the actual data in the form of a pathname
• Examples of External files
– feature attribute tables (.pat, .aat, .nat)
– coordinate tables (.tic, bnd)
• Both types are accessed the same way from within INFO or TABLES
13
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
SELECT and RESELECT
•
In Tables and INFO, these commands generally must be issued before you can work on
tables.
SELECT selects a file (table), and by implication all records within it. Any commands
subsequently executed will affect all the records in the table. You must select a table in Info or
Tables before you can work on it. To modify only specific records, use RESELECT to create a
subset of records after you have issued SELECT to identify the table.
SELECT <info_file_name>
To clear selected table, issue SELECT without a name (you seldom do this, since normally you
simply select another table.)
RESELECT (reduce select, or record select) selects a subset of records from the currently
selected data file. (In INFO and Tables, you must have issued SELECT first to select this data
file.) Selection criteria are based on logical expressions:
RESELECT {BY | FOR} <logical_expression>
RESELECT FOR ED-YRS LE 4 OR PAY-RATE GT 17.00
ASELECT adds additional records to the selected set -- requires a logical expression to select
additional records.
To clear a selection, use ASELECT without a logical expression to clear selection; in effect, this
adds back all records in the file, thus clearing all previous selections.
NSELECT switches the set of selected and unselected records.
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
14
Sample TABLES Session
Arc: Tables (starts tables)
Enter command: directory (will list all files, internal and external, within INFO)
Enter command: select pub.pat (you must select a file before operating on it)
Enter command: items (will display item names in currently selected file)
Enter command: list (will display data in currently selected file)
Enter command: quit (will quit Tables and return to Arc prompt)
Sample INFO Session
Arc: info
ENTER USER NAME> ARC (must switch to all CAPITAL letters)
ENTER COMMAND> DIR
(abbreviation for directory)
ENTER COMMAND> SELECT EDGEROAD.AAT (selects table)
ENTER COMMAND> IT
(abbreviation for items)
ENTER COMMAND> Q STOP
(to leave INFO)
15
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Getting Attribute Data into Arc/INFO
Step 1: DEFINE a new INFO data file “template”to hold
the attributes;
Data file must contain either
• the coordinate data needed to generate a new coverage, or
• a variable that can be used to relate or join to an existing
coverage feature attribute table.
Step 2: ADD the attribute values to the INFO data file,
either by
• entering each value at the keyboard, or
• ADD FROM (or GET) an existing text file.
Alternate: Use JOINITEM or RELATE to “connect” an
INFO data file to the feature attribute table for the
coverage
16
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Step 1: Getting Attribute Data into Arc/INFO
• DEFINE - Issue the DEFINE command with the file name to create a new
data file template. You will be prompted for the attribute name, size, and
type of each item in a new data file.
Arc: tables
enter command: define landuse.dat
item name: landuse-id
item width:
4
output width:
5
item type:
B
item name:
lu-code
item width:
3
output width:
3
item type:
I
item name: <return> (to end)
(common name and definitions to match
attribute table to which you wish to join)
(new variable)
• If you make a mistake while defining the file, the command ERASE will
delete the file, and you can start over. Or use ALTER or MODIFY.
• Look at what you have created with the ITEMS command.
17
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Step 2, page 1 Getting Attribute Data into
Arc/INFO
ADD - use to interactively enter attribute data into an INFO data file
Arc: tables
Enter command: select Landuse.dat (file
we created with the DEFINE command)
Enter command: add
•
Sample table
Landuse-id
1
Landuse-id> 59
Lu-code>
400
2
Landuse-id> 60
Lu-code>
200
3
Landuse-id> 61
Lu-code>
400 ………...
59
60
61
62
63
(LIST command)
lu-code
400
200
400
300
100
6
Landuse-id> <return>
If any item values are wrong, you can use the UPDATE command to
change the value of a particular record - works on one record at a time.
18
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Step 2, page 2 Getting Attribute Data into
Arc/INFO
• You can use the GET or ADD FROM commands to read
attribute values directly from an ASCII file or INFO file.
•
•
Remember, when you are in INFO, you are in the /info folder. If reading an ascii
file, you must indicate that the file is stored up one directory level.
GET will put the data values from an existing file, which can be an ascii file, a
binary file, or an INFO file, with fixed record length, fixed item length, into an
empty INFO table that has been defined to match the ascii file field definitions.
enter command> GET ../airports.txt COPY (using INFO)
tables> get airports.txt copy
(using tables)
•
ADD FROM requires an ASCII comma-delimited file, which may have been
created with a system text editor, or by other programs such as spreadsheets or
statistical systems. The items in the delimited data file must match the items
definitions of the selected file. Character items containing blanks must be
enclosed with a “double quote”.
– Enter command> ADD FROM ../airports.dat
– Tables> add from airports.dat
•
7/12/2016 UT Dallas
19
POEC 6382 Applied GIS Software
Example using ADD FROM
• Remember that you are in INFO and you must specify the full
pathname to the ascii file, or indicate a move up the directory
path:
Arc: tables
tables> SELECT LANDUSE.DAT (file previously created with DEFINE)
tables> ADD FROM C:/USR/DLAUDER/DATA/LANDUSE.TAB
tables> LIST
tables> Q
• The records are added to landuse.dat in the same order they were
listed in the ASCII data file
• Landuse.dat can now be joined/related to a feature attribute table.
• In the input file, text items containing blanks must be
enclosed in “double quotes” otherwise the blanks are also
treated as delimiters and data is split among multiple items
(this is not in ArcDOC!)
20
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Getting Attribute Data into Arc/INFO
from a DBF format
• Database files (.dbf) can be converted from dbf to an INFO file format
with a conversion command at the Arc prompt:
Arc: DBASEINFO <dbase_file> <info_file> {DEFAULT | DEFINE}
Arc: dbaseinfo air_data.dbf airdata
• After conversion to INFO format, the INFO file can be joined or
related to the coverage feature attribute table.
• Remember, files in INFO cannot be seen by name in your NT Explorer
Window -- they reside within the INFO folder with an internally
generated name (e.g. arc0003.dat and arc0003.nit). You can confirm
their existence by using the DIR INFO command in Arc, or just DIR in
INFO.
21
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Modifying Item(Variable) Definitions in a File
• MODIFY is used to replace (change), insert and delete item
definitions such as their name type or width BEFORE addition of data
records to the template file. Must have an empty template--item
definitions have been defined but attribute data has not yet been added
(or all data records have been PURGED).
R = replace
I = insert
D = delete
L = list
• ALTER is used to alter item definitions such as their name, type, or
width AFTER addition of data records to the file. Items must be empty
to decrease column width or decimal precision.
• REDEFINE allows you to access contiguous items or parts of items in
an INFO file as if it were another item.
Items are formatted based on the columns (space holders) they occupy.
This allows the user to view and manipulate the data in those columns
as a new item.
22
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Modifying Record (item) Values in a File
•
UPDATE allows you to change the values of specific records for any item in
the currently selected file. UPDATE first prompts you for the number of the record
to update. The current item values for that record are then listed, followed by an Edit?
Prompt. To change a value, type the name of the item you want to change followed by
an “=“ and the new value:
Enter record number: 2 (will list current values for that record)
edit? soil_type = 30
(or soil_type = ‘clay’ if defined as character)
edit? <return>
Enter Record Number: <return>
•
CALCULATE assigns new values for a numeric data item for the
currently selected records (Tables: N, I, F, B, D; INFO: I, N, D).
enter command> calculate item_name = new_value
enter command> calculate item_name_2 = item_name_1 * value
Same functionality as CALCULATE in ArcPlot. Note spaces surrounding = sign!!
•
MOVE assigns new character data item (C) for selected records
enter command> move ‘new char string’ to item_name
enter command> move item_name_1 to item_name_2
For the same functionality in ArcPlot use MOVEITEM. (MOVE is very different in
ArcPLot!)
•
PURGE removes all selected records from a table (but item definitions
remain--handy, for example, if ADD FROM screws up, and you need to try
again). KILL deletes the entire file.
23
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
OUTPUT
•
•
•
•
OUTPUT will output data from an INFO file into an ascii file
Must be done from INFO (not Tables)
When creating an ascii file, must precede the file name with the symbols to move
up one directory level ( ..\ ) to be out of info folder
If there are more than 999 records, INFO will insert a comma in the record number
(e.g. 1,000). To prevent the commas:
enter command> CALC $COMMA-SWITCH = -1
•
Example to create an output file with user-id and x,y coordinates that will be used
to generate a point coverage:
arc: INFO
ENTER USER NAME> ARC
ENTER COMMAND> SELECT
AIRPORTS
ENTER COMMAND > CALC $COMMA-SWITCH = -1
ENTER COMMAND > OUTPUT ..\points.gen
ENTER COMMAND > PRINT COVER-ID, ‘,’, LONG,
‘,’, LAT (adds commas also)
ENTER COMMAND > PRINT ‘END’
ENTER COMMAND > OUTPUT ARC.NSP
(directs future output back to normal default)
ENTER COMMAND> Q STOP
24
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Coverage Generation
•
•
•
You can generate a new coverage from any comma-delimited ascii file that
contains a unique identification number (will become the <cover>-id variable,
or user-id) and coordinate pairs for points, lines, or polygons.
Prior to creating a coverage, determine if you would like single precision
(coordinate accuracy to 3 decimals for geographic decimal degree) or double
precision (coordinate accuracy to 6 decimals)
EXAMPLE FOR POINTS:
– Arc:
precision double
– Arc:
generate airports
– Generate: input airports.gen
– Generate: points
– Generate: quit
– Arc:
Remember to build topology after creation of a new coverage
– Arc:
build airports point
•
Coverages are covered in more detail in the “Coverage” lecture!
25
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Managing and Changing Tables in Arc/ArcEdit/ArcPlot
• Some table change and management can also (or must) be done
outside of Tables and INFO in Arc, ArcEdit or ArcPlot.
• Some of the commands previously discussed for Tables and INFO will
also work outside Tables and INFO (altho exact usage may differ)
• Material which follows provides examples of this
26
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Modifying item definitions in Feature Attribute Tables
• ADDITEM
add an item to an existing table
ADDITEM <in_info_file> <out_info_file> <item_name> <item_width>
<output_width> <item_type> {decimal_places} {start_item}
Example: Arc: additem pub.pat pub.pat relat-id 12 12 N 2 city
- provides column and title only, no data is assigned
- if the <out_info_file> is the same as the <in_info_file>, the existing
<in_info_file> will be replaced
• DROPITEM drop an item from an existing table
DROPITEM <in_info_file> <out_info_file> {drop_item}
Example: dropitem pub.pat pub.pat relat-id (to drop item relat_id)
or
dropitem pub.pat pub.pat (you will be prompted for
names of all items to be dropped)
27
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Modifying numeric records in Feature Attribute Tables
CALCULATE assigns numeric values to items.
CALCULATE <cover> <feature_class> <target_item> = <arithmetic_expression>
or
CALCULATE <info_file> INFO <target_item> = <arithmetic_expression>
Example: Arcplot: calculate pub point key = 1
Arcplot: calculate pub.pat INFO key = 1
Example 2: Arc: tables
Enter command: select aircover.pat
Enter command: calculate air-id = aircover-id
Enter command: quit
Arc: list aircover.pat (to make sure variables correctly calculated)
- Requires that item key has been defined as numeric
- The CALCULATE command operates on all currently selected features within the
coverage, or all selected records in the INFO file. This may be one, some or all records.
Note: there must be a space on each side of the equal sign: a
= b
28
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Modifying character records in Feature Attribute Tables
• MOVEITEM assigns a character value to a character item
MOVEITEM <cover> <feature_class> <’character_string’ | source_item>
{TO} <target_item>
or
MOVEITEM <info_file> INFO <’character_string’ | source_item> {TO}
<target_item>
Example: Arcplot: moveitem pub point ‘blue’ to key
Arcplot: moveitem pub.pat INFO ‘blue’ to key
- Requires that item key has been defined as character
- Character strings are always placed in single quotes
- The MOVEITEM command operates on all currently selected features within
the coverage or records from an INFO data file: this could be one, some or all
records in the file
-use the command MOVE in INFO and Tables for same functionality as
MOVEITEM in Arc and ArcPlot
29
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Merging Tables with JOINITEM
•
JOINITEM permanently merges two INFO data files based on a shared item
JOINITEM <in_info_file> <join_info_file> <out_info_file> <relate_item>
{start_item} {LINEAR | ORDERED | LINK}
- The <relate_item> must exist for both files.
- The <relate_item> must have the same definitions (i.e. name, type, width, output) in
both files.
-{LINEAR | ORDERED | LINK} specifies how <join_info_file> records are matched
to <in_info_file> records.
LINEAR - both files can be sorted in any order. This is the default option.
ORDERED - the <join_info_file> must be sorted on <relate_item>.
LINK - The <relate_item> value in each record of <in_info_file> indicates the internal
record number in <join_info_file> which is to be merged.
- The speed of execution will depend on the organization of the files being joined. In
general, LINK is the fastest matching operation, then LINEAR with an indexed
<relate_item>, and then ORDERED. The fastest option, LINK cannot be applied to
most cases.
Hints: --use the LINEAR (default) option-- slower but safer
--when adding attribute data to a coverage, the coverage must be the in_file
--use same name for in_file and out_file--otherwise all the associated spatial
files are not available.
Note: altho. we talk of joining tables, the command is JOINITEM. Do not use JOIN,
which is a very specialized ArcEdit command used for joining lines on a map.
30
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Connecting Tables with RELATE
• A RELATE temporarily associates data files based on a common item
occurring in two files.
• Although a relate is temporary, the association between files can be
saved.
• Types of relates:
– One-to-one relate - the values for the common item are unique in each file
being related
– Many-to-one relate - many records in the main file may be matched to one
record in the related file. Example: road types, lookup tables
• Command RELATE establishes or modifies the relate environment.
Up to 100 relates can be stored in a single relate table.
RELATE <ADD|DROP> add or drop a relate. Will enter a dialog to specify
properties -- see below.
RELATE <RESTORE | SAVE> <info_file> bring back a relate from a
previous session, or save one for a future session
RELATE LIST {relate} lists properties of either all the relates that are
current or just the relate you specify
31
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Creating a Relate Environment
• RELATE ADD requires the following elements to be specified:
– Relation name: Name to reference the relate
– Table identifier: The name of the data file (in INFO or other RDBMS) to which you
want to relate
– Database name: Where the related files is stored (e.g. INFO)
– INFO item: The item name in the feature attribute table that will be matched to the
relate column. These names do not have to be the same
– Related column: The item in the related data file to match the INFO item
– Relate type: Specify the search method: Linear, Ordered, Link
– Relate access: Sets the access rights to the related data file. Can be Read/Write
(RW), Read-Only (RO), or the same as the current file (Auto)
Arc: relate add
Relation Name: sorel
Table Identifier: soil (may need to specify full path name if other than current directory)
Database Name: INFO
INFO item: soil_type
Relate column: soil_type
Relate type: ordered
Relate access: RW
Relation Name: (starts over -- hit return to end addition of relates)
32
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Using the Relate Environment
• The relate environment is usable from ARC, TABLES, ARCPLOT and
ARCEDIT. It is not usable from INFO.
• Items out of related files can be used in Arc/INFO anywhere that an
item name is specified.
• A relate does not store the table from which the relate operates;
therefore, multiple coverages can be related to the same data file
• When using ADD, if a relation name already exists in the current set of
relates, it is replaced by the new relate with the same name
• The general form for using fields out of related files is:
relation name//INFO item name
If the INFO data file to which we created a relate named SOREL also
contains an item called distance, we can create a distance buffer:
Usage: BUFFER <in_cover> <out_cover> {buffer_item}
Arc: buffer soils soilbuf sorel//distance
33
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Manipulating the Relate Environment
• RELATE LIST
– Will list out all current relates
• RELATE SAVE <file_name.rel>
– Creates a relate file (INFO file) that stores relates
– Appends relates to an existing relate file
– Each relate is one record in the relate file; can store 100 relates in one file
• RELATE RESTORE <file_name.rel>
– Establishes the current (active) relate environment
• RELATE DROP <file_name.rel>
– Drops a relate from all Arc/INFO modules
– Will prompt for relation name to drop: typing $ALL at the Relation Name
prompt will drop all relates
34
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
RELATE versus JOIN
• Advantages of RELATE
– Operations on coverages with extended feature attribute tables take more
time and machine resources.
– Can make the updating process easier and faster because it keeps
descriptive data segregated from the spatial data. Can replace the attribute
data regularly.
– Allows separate departments in an organization to access the same
coverage while keeping their own descriptive data available in separate
files.
– Relating data allows you to keep some of your data in another RDMBS,
such as Oracle.
• Advantages of JOIN
– Simpler for projects of small scope.
– When files are joined, there are fewer files and relationships between files
to keep track of.
35
7/12/2016 UT Dallas
POEC 6382 Applied GIS Software
Related documents
Download