CH 4-Querying Gis Data
CH 4-Querying Gis Data
Introduction
One of the defining characteristics of GIS is the ability to ask
questions (and get answers) in a spatial context. These questions or queries
are requests for information that are posed in a specific fashion. When a
query is performed to obtain and answer to a spatial question, the data are
accessed through the basic elements of this structure which is made up of
tables, fields, data sets, values and connections.
The query operator done using GIS software, through the user
interface, query functions. The selective display and retrieval of information
based on these queries are essential components of any geographic
information system (GIS).
Generally, there are two types of GIS queries: attribute and location
(spatial), but there are three basic methods for searching and querying
attribute data: (1) selection, (2) query by attribute (or select by Attribute),
and (3) query by geography or select by location (spatial query).
GIS is powerful because it can use both attribute and spatial queries
to get answers with far less effort or answer questions that would not be
practical to answer using any other method.
Selection
Selection represents the easiest way to search and query spatial data
in a GIS. Selecting features highlight those attributes of interest, both on-
screen and in the attribute table, for subsequent display or analysis. To
accomplish this, one selects points, lines, and polygons simply by using the
cursor to “point-and-click” the feature of interest or by using the cursor to
drag a box around those features. Alternatively, one can select features by
using a graphic object, such as a circle, line, or polygon, to highlight all of
those features that fall within the object. Advanced options for selecting
subsets of data from the larger dataset include creating a new selection,
selecting from the currently selected features, adding to the current
selection, and removing from the current selection.
Query by Attribute
Map features and their associated data can be retrieved via the
query of attribute information within the data tables. For example, search
and query tools allow a user to show all the census tracts that have a
population density of 500 or greater, to show all counties that are less than
or equal to 100 square kilometers, or to show all convenience stores within
1 mile of an interstate highway.
Attribute queries ask for information from the tables associated with
features or from stand-alone tables associated with the GIS. Attributes can
be numeric values, text strings, Boolean values (i.e., true or false), or dates.
This kind of query is similar to a query made to any database; however,
when using a GIS, the answers (i.e., the features related to the records
selected by the process) are highlighted on the map as well as in the table.
For example, you could ask if one or more features are located within
a certain distance of other features, are contained by another feature,
intersect other features, or possess another of the relationships defined by
spatial operators. For example, a GIS provides robust tools that allow for
the determination of the number of schools within 10 miles of a home.
Several spatial query options are available, as outlined here. Throughout
this discussion, the “target layer” refers to the feature dataset whose
attributes are selected (schools), while the “source layer” refers to the
feature dataset on which the spatial query is applied.
For example, if we were to use a state boundary polygon feature dataset to
select highways from a line feature dataset (e.g., select all the highways that
run through the state of Arkansas), the state layer is the source, while the
highway layer is the target.
While the SELECT and FROM clauses are both mandatory statements
in an SQL query, the WHERE is an optional clause used to limit the output
set. The ORDER BY and HAVING are optional clauses used to present the
information in an interpretable manner.
INTERSECT
The highlighted blue and yellow features are selected because they are within the selected
distance of the red features; tan areas represent buffers around the various features.
The highlighted blue and yellow features are selected because they completely contain the red
features.
This query selects those features in the target layer whose entire
spatial extent occurs within the geometry of the source layer. The “are
completely within” query allows for points, lines, or polygons as the target
layer, but only polygons can be used as a source layer (Figure below)
The highlighted blue and yellow features are selected because they are completely within the red
features.
features.
SHARE A LINE SEGMENT.
The highlighted blue and yellow features are selected because they share a line segment with the
red features.
TOUCH THE BOUNDARY OF.
The highlighted blue and yellow features are selected because they touch the boundary of the red
features.
ARE IDENTICAL TO.
This spatial query returns features that have the exact same
geographic location. The “are identical to” query can be used on points,
lines, or polygons, but the target layer type must be the same as the source
layer type (Figure below)
The highlighted blue and yellow features are selected because they are identical to the red
features.
This selection criteria returns features that share a single vertex but
not an entire line segment. The “are crossed by the outline of” query allows
for line or polygon layers to be used as both source and target layers (Figure
below)
The highlighted blue and yellow features are selected because they are crossed by the outline of
features.
Using Operators
When selecting by attribute, LIKE and NOT are often used to compare
text strings and match patterns, often employing wildcards (Alternatively
referred to as a wild character or wildcard character, a wildcard is a symbol
used to replace or represent one or more characters. The most common
wildcards are the asterisk (*), which represents one or more characters and
question mark (?) that represents a single character). Wildcards can replace
one character or a group of characters that are unknown. The character
used depends on the data source being queried. For personal
geodatabases, use a question mark (?) for a single character and an asterisk
(*) for a group of characters. For shapefiles, ArcSDE geodatabase feature
classes, and other types of data, use an underscore (_) to replace a single
unknown character and a percentage sign (%) to replace a group of
characters. ArcMap will detect the type of database being queried and
adjust the wildcard characters available through the Select by Attribute
dialog box. LIKE is a good operator for finding text strings that contain
variant spellings or possibly misspellings, of a text string. Rather than using
an equal sign followed by the search term enclosed in quotes, use LIKE and
enclose the search term and a wildcard character with quotes. Like the
characters used for wildcards, the syntax used when querying dates
depends on the underlying database. ArcMap automatically writes the
proper syntax when you double-click on a date value in the Unique Values
list of the Select by Attribute dialog box. The choice of spatial operator (i.e.,
the relationship tested by the query) depends on the types of features that
will be used for the source and filter.