Working With Spatial Data
Working With Spatial Data
CHAPTER
5
Working with Spatial Data
A third element of the SAS data set is one or more indexes. A SAS index contains
the data values of the key variables that are paired with a location identifier for the
observation that contains the variable. The value/identifier pairs are ordered in a
B-tree structure that enables the engine to search by value.
56 SAS/GIS Data Sets 4 Chapter 5
SAS data sets can be indexed by one or more variables, known as key variables. SAS
indexes are classified as simple or composite, according to the number of key variables
whose values make up the index.
and processing capacity. Spatial data that are not carefully managed can become too
large for easy use.
Following are five actions that you can take to manage the size of your spatial data
sets. You need to perform most of these actions before importing your data into SAS/
GIS.
Reduce the spatial extent of the data.
Do not store a larger area than you need. If you need a map containing one state,
do not store a map containing all the states for a region. For example, if you need
to work with a map of Oregon, do not store a map containing all of the Pacific
Northwest.
Store only the features that you need.
If you do not need features such as rivers and lakes, do not store these features in
your spatial data.
Limit the amount of detail to what is necessary for your application.
If you are using a map for which you don’t require highly detailed boundaries,
reduce the detail level and save storage space. If you are using SAS/GRAPH data
sets, you can use PROC GREDUCE to reduce the detail level. If you are using a
data set from another source, you’ll have to reduce the level of detail before
importing the data set into SAS/GIS.
Reduce the number of attributes that are stored with the spatial data.
If you don’t need an attribute, and don’t think you will ever need it again, delete it
from your spatial data.
Reduce the size of variables that are stored in the spatial data
Also, you might want to reduce the size of each variable, if possible. That is,
examine the method that you use for storing your variables and determine if you
can safely reduce the variable size that you use to store them.
For example, if you have a numeric variable that contains a code that can be a
maximum of two digits, perhaps it would be better to store it in a two-digit
character variable rather than in an eight-byte numeric variable. Change the
variables’ defined types or lengths in a DATA step after you complete the import.
Of the five actions, reducing the number of attributes is the easiest to perform. Use
the Import window that you can access by selecting Modify Composites from the GIS
Spatial Data Importing window to remove and drop unneeded composite variables from
your data set as it is imported.
Table 5.1 Composites and Variables Specific to the ARC/INFO Import Type
X X X X coordinate.
Y Y Y Y coordinate.
1
A = Area
C = Classification
X = X coordinate
Y = Y coordinate
2 Names in single quotation marks, such as ’COVERAGE’ and ’ATTTRIB,’ are GIS composite names.
Table 5.2 Composites and Variables Specific to the Digital Line Graph (DLG) Import Type
X X X X coordinate.
Y Y Y Y coordinate.
1
A = Area
C = Classification
X = X coordinate
Y = Y coordinate
Table 5.3 Composites and Variables Specific to the DXF Import Type
1
A = Area
C = Classification
Table 5.4 Composites and Variables Specific to the Genline Import Type
X X X X coordinate.
Y Y Y Y coordinate.
1
C = Classification
X = X coordinate
Y = Y coordinate
Table 5.5 Composites and Variables Specific to the Genpoint Import Type
X X X X coordinate.
Y Y Y Y coordinate.
1
C = Classification
X = X coordinate
Y = Y coordinate
Table 5.6 Composites and Variables Specific to the MapInfo Import Type
1
A = Area
C = Classification
Table 5.7 Composites and Variables Specific to the SAS/GRAPH and Genpoly Import Types
1
A = Area
Working with Spatial Data 4 Spatial Entries 63
Table 5.8 Composites and Variables Specific to the TIGER and DYNAMAP Import Types
LONGITUDE X X Longitude.
LATITUDE Y Y Latitude.
1
A = Area
C = Classification
ADDR = Address
ADDRP = Address Prefix
ADDRS = Address Suffix
X = Longitude
Y = Latitude
Spatial Entries
A spatial entry is a SAS catalog entry of type GISSPA that identifies the spatial data
sets for a given spatial database and defines relationships between the variables in
those data sets.
SAS/GIS software supports simple spatial entries and merged spatial entries as
follows:
64 Spatial Entries 4 Chapter 5
COMPOSITE statement
Creates or modifies composites that define the relation and function of variables in
the spatial data sets. The composite definition is stored in the spatial entry. See
“COMPOSITE Statement” on page 89 for details about creating or modifying
composites.
POLYGONAL INDEX statement
Updates the list of available index names stored in the spatial entry. See
“POLYGONAL INDEX Statement” on page 95 for details about creating or
modifying polygonal indexes.
LATTICE statement
Updates the lattice hierarchy stored in the spatial entry. See “LATTICE
Statement” on page 98 for details about defining lattice hierarchies.
You can view a formatted report of the contents of a spatial entry by submitting a
SPATIAL CONTENTS statement in the GIS procedure.
See “SPATIAL Statement” on page 84 for details about using the GIS procedure to
create, modify, or view the contents of spatial entries.
Coverage Entries
A coverage entry is a SAS catalog entry of type GISCOVER that defines the subset,
or coverage, of the spatial data that are available to a map. SAS/GIS maps refer to
coverages rather than directly to the spatial data.
A coverage entry contains the following elements:
3 A reference to the root spatial entry.
3 A WHERE clause that describes the logical subset of the spatial data that are
available for display in a map.
Note: The clause WHERE=’1’ can be used to define a coverage that includes all
the data that are in the spatial database. WHERE=’1’ is called a universal
coverage. 4
The WHERE clause binds the coverage entry to the spatial data sets that it
subsets. The WHERE clause is checked for compatibility with the spatial data
when the coverage entry is created and also whenever a map that uses the
coverage entry is opened.
3 The maximum and minimum X and Y coordinates in the portion of the spatial
data that meets the WHERE clause criteria for the coverage.
These maximum and minimum coordinates are evaluated when the coverage is
created. The GIS procedure’s COVERAGE CREATE statement reads the matching
chains and determines the extents from the chains, the XMIN, YMIN, XMAX, and
YMAX variables. If you make changes to the chains, nodes, and details data sets
that affect the coverage extents, use the COVERAGE UPDATE statement to
update the bounding extent values.
Multiple coverage entries can refer to the same spatial entry to create different
subsets of the spatial data for different maps. For example, you could define a series of
coverages to subset a county into multiple sales regions according to the block groups
that are contained in each of the regions. The spatial data for the entire county would
still be in a single spatial database that is represented by the chains, nodes, and details
data sets and by the controlling spatial entry.
Coverage entries are created and modified by using the COVERAGE statement in
the GIS procedure. You can view a formatted report of the contents of a coverage entry
by submitting a COVERAGE CONTENTS statement in the GIS procedure. (The
66 Layer Entries 4 Chapter 5
contents report for a coverage entry also includes all the contents information for the
root spatial entry as well.)
See “COVERAGE Statement” on page 100 for more information about creating,
modifying, or viewing the contents of coverage entries.
Layer Entries
A layer entry is a SAS catalog entry of type GISLAYER that defines the set of
features that compose a layer in the map. A layer entry contains the following elements:
3 A WHERE clause that describes the common characteristic of features in the layer.
The WHERE clause binds the layer entry to the spatial data even though the
WHERE clause is stored in the layer entry. The layer is not bound to a specific
spatial entry, just to those entries that represent the same type of data. Therefore,
a layer that is created for use with data that are imported from a TIGER file can
be used with data that are imported from any TIGER file; however, not all
filetypes can take advantage of this behavior. The WHERE clause is checked for
compatibility with spatial data when the layer entry is created and also whenever
a map that uses the layer entry is opened.
Note: When you define area layers, you can specify a composite as an
alternative to specifying an explicit WHERE clause. However, the layer entry
stores the WHERE clause that is implied by the composite. For example, if you
specify STATE as the defining composite for a layer, and the STATE composite
specifies the following variables: VAR=(LEFT=STATEL,RIGHT=STATER), then
the implied WHERE clause that is stored in the layer entry is ’STATEL NE
STATER’. 4
3 Option settings for the layer such as the layer type (point, line, or area), whether
the layer is static or thematic, whether it is initially displayed or hidden, whether
detail points are drawn for the layer, and the scales at which the layer is
automatically turned on or off.
3 The graphical attributes that are necessary to draw the layer when it is displayed
as a static layer.
3 The attribute links, theme range breaks, and graphical attributes if the layer
contains themes.
See “LAYER Statement” on page 103 for more information about creating, modifying, or
viewing the contents of layer entries.
Map Entries
A map entry is a SAS catalog entry of type GISMAP. Map entries are the controlling
entries for SAS/GIS maps because they tie together all the information that is needed
to display a map. A map entry contains the following elements:
3 A reference to the coverage entry that defines the subset of the spatial data that
are available to the map. Note that the map entry refers to a particular coverage
of the spatial data rather than directly to the spatial entry.
3 References to the layer entries for all layers that are included in the map.
3 References to any attribute data sets that are associated with the map, for
example, the data sets that are used for the map actions, along with definitions of
how the attribute data sets are linked to the spatial data.
3 A reference to the SAS data set that contains labels for map features.
3 Definitions for the actions that can be performed.
Working with Spatial Data 4 Overview 67
Composites
For most operations that involve the spatial database, you refer to composites of the
spatial data variables rather than directly to the variables in the spatial data sets. A
composite consists of the following elements:
3 A variable association that identifies which variable or variables in the spatial
database comprise the association. The variable association can specify a single
variable, a pair of variables that define a bilateral (left-right) association, or two
pairs of variables that define the start and end of a directional (from-to) bilateral
association.
3 A class attribute that identifies the role of the composite in the spatial database.
For example, if the chains data set has a variable named FEANAME that contains
feature names, you can create a composite for the FEANAME variable that assigns the
class attribute NAME to indicate that the association represents feature names. Or, if
the chains data set has COUNTYL and COUNTYR variables that contain the codes for
the counties on the left and right sides of the chains, you can create a composite named
COUNTY. The composite identifies the bilateral relationship between these two
variables and assigns the class attribute AREA to indicate that the association defines
county areas in the spatial data.
Composites are created and modified using the COMPOSITE statement in the GIS
procedure. Composite definitions are stored in the spatial entry.
See “COMPOSITE Statement” on page 89 for more information about creating or
modifying composites.
Overview
MERGE is an option of the GIS procedure’s SPATIAL statement that lets you build a
new spatial entry by referencing two or more existing spatial entries. The dependent
data sets for the spatial entries are not actually combined when you use the MERGE
argument; the new spatial entry includes them by reference.
68 Syntax 4 Chapter 5
Syntax
The MERGE option syntax follows.
MERGE=(<[Link].>spatial-entry-1 <, ..., <[Link].>spatial-entry-n>)
<EDGEMATCH | OVERLAP>
Note: Keep in mind that MERGE is specified as an option on a SPATIAL
statement. 4
If you specify a one-level name for any of the entries to be merged, the spatial entry
is assumed to be in the catalog that is specified in the CATALOG= argument with the
PROC GIS statement or in the most recently issued CATALOG statement. An error
occurs if you have not specified a catalog prior to specifying the names of the entries
you want to merge.
EDGEMATCH
Locates common boundaries between the merged spatial entries and updates
missing left- or right-side composite variable values in the chains data that lie on
the boundaries.
In other words, the EDGEMATCH operation compares the chains in the
different data sets and finds those chains that map the same feature. When it
finds the same chain in both data sets, it replaces any missing left- or right-side
composite values in either chain with the valid values from the other data set.
EDGEMATCH also creates a merged spatial entry that references other spatial
entries (either merged or simple) that you specified with the MERGE option.
EDGEMATCH rewrites the specified chains data sets. You cannot reverse this
operation.
OVERLAP
Merges spatial entries without attempting to match boundaries. OVERLAP is the
default behavior of the MERGE argument. The OVERLAP argument creates a
merged spatial entry that references the specified spatials entries (either merged
or simple) .
OVERLAP does not rewrite the specified chains data sets.
For more information, see “SPATIAL Statement” on page 84.
a missing value. The corresponding chains in the Vermont chains data set contain the
Vermont FIPS code of 50 on one side and a missing value on the other side. An
edgematch merge of the two data sets locates these common boundary chains in each
data set and replaces the missing values with the correct FIPS code for the adjoining
state. It will also create a merged spatial entry that references the New Hampshire and
Vermont simple spatial entries.
The EDGEMATCH operation creates a single-merged spatial entry by which you can
create a map of the two states. It also adds the Vermont FIPS code to the appropriate
chains in the New Hampshire data set, and adds the New Hampshire FIPS code to the
corresponding chains in the Vermont data set.
The SAS System Help window opens. From this window select the following:
Sample SAS Programs and Applications I SAS/GIS
You can use this sample map with the SAS/GIS interface and the GIS procedure.
2 Defining a layer with WHERE=’1’ displays all of the features in the underlying
spatial data that have that type. For example, if you have a map with a point
layer that contains capital cities, and you add a new point layer for grocery store
locations by using WHERE=’1’ for the layer definition, the grocery store layer will
display all of the point features in the spatial data. This layer includes capital
cities, grocery stores, and all other point features in the spatial data.
You may find this confusing if you are not aware that all point features are
being displayed when you intend to display only one layer.
You may encounter this situation because the GENPOINT import, by default,
defines all point layers with a WHERE=’1’ clause. You can use the Modify layers
button on the GIS Spatial Data Importing window to redefine the layer definition
to be a WHERE clause that uniquely identifies the set of points in the layer. If the
layer already exists on the map, you can use the LAYER statement in PROC GIS to
redefine the layer with a WHERE clause that defines only those points in the layer.
The correct bibliographic citation for this manual is as follows: SAS Institute Inc.,
Working with Spatial Data Using SAS/GIS ® Software, Version 8, Cary, NC: SAS Institute
Inc., 1999.
Working with Spatial Data Using SAS/GIS® Software, Version 8
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA.
ISBN 1–58025–519–1
All rights reserved. Printed in the United States of America. No part of this publication
may be reproduced, stored in a retrieval system, or transmitted, by any form or by any
means, electronic, mechanical, photocopying, or otherwise, without the prior written
permission of the publisher, SAS Institute, Inc.
U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of the
software by the government is subject to restrictions as set forth in FAR 52.227–19
Commercial Computer Software-Restricted Rights (June 1987).
SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.
1st printing, October 1999
SAS® and all other SAS Institute Inc. product or service names are registered trademarks
or trademarks of SAS Institute Inc. in the USA and other countries.® indicates USA
registration.
Other brand and product names are registered trademarks or trademarks of their
respective companies.
The Institute is a private company devoted to the support and further development of its
software and related services.