TEACHING GEOG 385.02/GTECH 785.02 
GIS APPLICATIONS IN SOCIAL GEOGRAPHY
Back to MP home page

GIS SG course homepage
Back to GIS SG schedule
GIS links and resources
Class Project


Vector analysis I: DB queries and map algebra

By the end of this lecture you should be able to:

  •  Understand how database query by location works in a vector GIS and how it is different from database query by location in a raster system.
  • Understand how database query by attribute (single and multiple) can be performed in a vector GIS and how both differ from raster.
  • Describe the vector equivalent of map algebra and how it is different from map algebra in raster systems.
  • Know that structured query language (SQL) is used to perform attribute queries and map algebra operations in vector GIS systems.

In vector systems, much of the analysis we are familiar with (review Tools for Raster Analysis) will be performed in the attribute database (attribute table) and the result will be mapped.

  • Database query by location and by attribute
  • Context operators
  • Distance operators
  • Map algebra

Our database queries and map algebra in raster involved the maps themselves (remember that the spatial and attribute components in raster are both represented within the raster image). In vector systems, however, database query and map algebra are operations within the attribute database/table independent of the spatial component.

Database query

This can be done in vector systems that have a

  • feature encoded vector format (like IDRISI) and
  • topologically encoded format (Arc/Info, ArcGIS – partial topology)

EXAMPLE: A vector layer/theme showing land parcels with an attribute database attached to it:
 
 

ID

Owner

Year purchased

Size

County

Landuse

Value

1

Smith

1921

2000

Broward

Industrial

300000

2

Brown

1933

500

Dade

Residential

90000

3

Adams

1991

1450

Broward

Residential

60000

 

 

 

 

 

 

n

 

 

 

 

 

 

Database Query by Location

Means: "What is at this location?" or more specifically in vector format "What attributes are associated with this feature?"

  • In raster format we can query individual pixels (using cursor) or groups of pixels using a feature definition image (e.g. EXTRACT).
  • In vector format we can query whole vector features (points, lines, polygons) or groups of these features. This is done by selecting a feature or group of features using the mouse/cursor.
  • In raster the coordinates of the cursor location or simply the cells of the feature image are used to query the database (image).
  • In vector a point in polygon method is used. Using the coordinates of the cursor, the GIS system identifies which polygon it belongs to (i.e. it is inside) and displays the attributes that correspond to that polygon.

In the example, if you click on a particular parcel the GIS will display, in tabular form, the attributes of this particular parcel.

NOTE: Because you are querying vector features as whole entities, you can click anywhere within this parcel but the result will be the same. In vector format all associated attribute values apply to the entire feature.

Database Query by Attribute(s)

Means: "Where is this attribute or this combination of attributes found?" or "What features have this attribute or combination of attributes?"

  • In raster, query by attribute involves reclassifying cell values (or re-assigning) and then (if multiple attributes) overlaying boolean images.
  • In vector, query by attribute is all done within the attribute table itself (no maps involved). Queries are built using SQL – structured query language. SQL is widely used in database management packages such as Microsoft Access, etc.

Database Query By Single Attribute

  • In raster, reclassification of pixel values to find areas that have attributes within a particular range (RECLASS, EDIT/ASSIGN in IDRISI).
  • In vector, specify the field that contains the attribute values of interest and then specify a value or a range of values using SQL (taking a range of data or categories and making it Boolean). All records with that value or range of values are then isolated and their corresponding features can be mapped.

Example: Select and map all parcels that are located in Broward country.

    • The attribute of interest is stored in the field [COUNTY].
    • The attribute value to isolate is "Broward."
    • The SQL query used will look like:

 ([COUNTY]= "BROWARD")

This will select two records from the attribute table (1 and 3). The associated features (parcels with ID 1 and 3 on the map) can then be identified on the map (colored differently, etc.).

Database Query By Multiple Attributes

  • In raster, overlay of boolean images is used to find areas where several attributes in a specified range occur simultaneously (e.g. intersection/logical AND). E.g. Areas under crops that are also between 700 and 1100 meters in elevation. Overlay can also perform the logical OR operation but we didn’t use it much.
  • In vector, this type of analysis is done in the attribute table/database.
    • The ranges of values for more than one attribute field are specified.
    • How these criteria will be combined (intersection or union) is also specified.
    • The result: all records that meet the specified criteria are selected and their associated features can then be mapped.

EXAMPLE of logical AND (INTERSECTION of attributes):
From the table of parcel information, select parcels that are located in Broward County AND have a size below 1500 (hectares?). Using SQL:

    • The first attribute is County, its value is "Broward"
    • The second attribute is Size and its value is <1500

 ([COUNTY] = "BROWARD") AND ([SIZE]<1500)

This will select one land parcel that meets both criteria (record 3 which corresponds to parcel 3 on the map).

EXAMPLE of logical OR (UNION of attributes):
From the table of parcel information, select all features that meet AT LEAST ONE of the criteria from the example above. Using SQL again:

([COUNTY] = "BROWARD") OR ([SIZE]<1500)

This query will select all three parcels in the database.

Multiple attribute query in vector format:

    • Is very powerful if you have large attribute databases for one vector layer (features with the same geography). (parcels, buildings, soils, countries, counties, etc.)
    • You can easily query your database and retrieve features using many different combinations of attributes.

ArcGIS is particularly good for this, because it has very simple SQL interface.

Map algebra

Map algebra is used to calculate new attribute values for spatial features using old attribute values from one or more fields. In vector this is all done within the attribute database.

It is somewhat different from map algebra in raster where we substituted entire maps into mathematical equations (remember that the spatial and attribute components in raster are the same thing…).

In raster, we used scalar, transform, and overlay operations on raster images.

  • This was cell by cell mathematical operations.
  • The result was a new raster image with new attribute values calculated from old attribute values.

  In vector, this is all done in the attribute database between attribute fields.

  • New attributes (fields) are created and their values calculated from the values of other attributes.
  • SQL is used for this too.

EXAMPLE: Using the existing attributes from the attribute table for parcels, we want to calculate a new attribute that indicates value of land per hectare (perhaps they are thinking of subdividing parcels…).

  • Create a new field "HECTVALUE" into which the new values will be placed.
  • Then do calculations using CALCULATE function in SQL:

[HECTVALUE] = [VALUE]/[SIZE]

  • New field will be filled with these new values.
  • Then you can display the new field values on the map or use them in queries

ID

Owner

Year purchased

Size

County

Landuse

Value

HectValue

1

Smith

1921

2000

Broward

Industrial

300000

150

2

Brown

1933

500

Dade

Residential

90000

180

3

Adams

1991

1450

Broward

Residential

60000

41.4

 

 

 

 

 

 

 

n