GRASS 5.7: Examples from US National Atlas

Tutorial HOME | Table of contents
GRASS 5.7 is currently under development. In case the examples described here do not work properly, you are kindly invited to send us further examples and/or code bugfixes/enhancements.

Getting the data
In this section we want to play abit with the (new) GRASS vector capabilities. This section is inspired by the paper "A Benchmark for Spatial Database Teaching" by Judy Djugash and Wei-Hsin Fu which focuses on the Open GIS Consortium's (OGC) Simple Features Implementation Specification.

The data sets are available from the National Atlas of the United States, in particular from the Map Layers Warehouse (this site is a dream for European GIS users).
We have to download following map layers:

First we have to create a GRASS location in decimal degrees on datum NAD83:
LOCATION: nationalatlas
mapset: user1
database: /usr/local/share/grassdata

Please specify the coordinate system for location 
   B   Latitude-Longitude
Please enter a one line description for location 
> nationalatlas

Do you wish to specify a geodetic datum for this location?(y/n) [y] y

Please specify datum name

Now select Datum Transformation Parameters
# 6 Used in Default nad83 region

                         DEFINE THE DEFAULT REGION
                       ====== DEFAULT REGION =======
                       | NORTH EDGE:74:50N____     |
                       |                           |
            WEST EDGE  |                           |EAST EDGE
            169:15E___ |                           |62:00W____
                       | SOUTH EDGE:13:20N____     |
           PROJECTION: 3 (Latitude-Longitude)         ZONE: 0

                             GRID RESOLUTION
                                 East-West:     0:05______
                               North-South:     0:05______

The data sets are provided in SHAPE format as well as SDTS format. GRASS can read both: A) Import of "Cities and Towns" as SHAPE file:

v.in.ogr dsn=citiesx020.shp output=cities
v.db.connect -p cities
d.vect cities icon=basic/circle fcolor=red
One attribute table is connected to the geometry. B) Import of "Cities and Towns" as SDTS file:
v.in.ogr dsn=CITXCATD.DDF output=CITX
v.db.connect -p CITX
d.vect CITX icon=basic/circle fcolor=red
Four attribute tables are connected to the geometry (accessible via 'field').

NOTE: Due to the map/tables size zooming before running a query with 'd.what.vect' is recommended.

We continue to work with the SHAPE files. Import of the "States" map:

v.in.ogr dsn=statesp020.shp output=states
d.vect map=states fcolor=255:255:220
v.in.ogr dsn=statesp020.shp output=roads
d.vect map=roads where="FEATURE='Limited Access Highway   Toll Road' or FEATURE='Limited Access Highway'" col=blue

The maps imported so far look like this:
GRASS USA National Atlas example

Ex 1) List the name and area of all the states that are adjacent to Minnesota in the State table.

d.what.vect states
#see attribute table

v.extract input=states output=minnesota where=STATE='Minnesota'
TODO - implement touch operator
Ex 2) List all the states that Interstate Route 90 passes through: TODO - implementation of cross operator

Ex 3) List all the cities, which are within 150 km of the Interstate Route 90 road.

#we are using the STRING_MATCH operator '~':
d.vect map=roads where="NAME ~ 'Interstate Route 90'" col=green

v.extract input=roads output=interstate90 field=1 new=0 where="NAME ~ 'Interstate Route 90'"

# buffer is in map units, here geodetic dist in Lat/Long = some arc seconds:
v.buffer input=interstate90 output=interstate90_150km buffer=0:00:23 tolerance=1
TODO - implementation of cross operator

Further Links (related software, SQL reference etc).

© 2003 Markus Neteler
Comments about this page | FAQ | Download | Support | Docs | Programming | Back 5.7 Tutorial Home
Last change: $Date: 2008-03-27 21:31:14 +0000 (Thu, 27 Mar 2008) $