[GRASSLIST:720] Re: tiger2k questions (listproc is driving me nuts!)

Radim Blazek blazek at itc.it
Tue Jul 15 03:54:58 EDT 2003


On Friday 11 July 2003 16:53, Frank Warmerdam wrote:
> OGR's data model for Tiger is closely tied to the underlying tiger data
> model. One downside of that is that the polygon layer consists of features
> with the polygons attributes but no geometries.

It is not downside but very important advantage for GRASS :)

> The geometries have to be
> built up from chains from the CompleteChain layer associated to the
> polygons using the contents of the PolyChainLink layer.
>
> It might be an interesting test of GRASS 5.1 to see if it is possible to
> import the raw attribute layers Polygon, and PolyChainLink and the
> CompleteChain line geometry layer, and use the information to build up the
> polygon geometries.

Yes, it is possible and much better than to import polygon rings, what
is the case for other OGR layers. Unfortunately it needs to use more
GRASS commands to get the result. Here is commented example how to 
import Tiger data (Postgres driver necessary):

# Import lines (boundaries+lines)
v.in.ogr dsn=input/2000/56015/ layer=CompleteChain output=t56015_CompleteChain

# Import centroids
v.in.ogr dsn=input/2000/56015/ layer=PIP output=t56015_PIP 

# Import table containing info about left/right side of boundaries
v.in.ogr dsn=input/2000/56015/ layer=PolyChainLink output=t56015_PolyChainLink

# Create a new table containing lines' cats and left/right info
# (in psql)
create table t56015_cp as select t56015_completechain.cat,
t56015_completechain.tlid, polyidl, polyidr from t56015_completechain, t56015_polychainlink
where t56015_completechain.tlid = t56015_polychainlink.tlid;

# Link the new table to lines
v.db.connect -o map=t56015_CompleteChain driver=pg database=tiger table=t56015_cp key=cat

# Extract boundaries (lines representing boundaries)
v.extract -t input=t56015_CompleteChain output=t56015_boundary_cat where="polyidl <> polyidr"

# Patch boundaries (so far type line) and centroids (still type point)
v.patch input=t56015_boundary,t56015_PIP output=t56015_patch

# Change lines to boundaries and points to centroids (like v.line2area)
v.type input=t56015_patch output=t56015 type=line,boundary,point,centroid

Note that I had problems with Tiger2002 and I have done some changes to
GRASS (e.g. v.in.ogr writes attributes for features without geometry now).

It is not very practical to use 8 commands instead of 1. As it is 
now, it cannot be too much simplified and the solution within GRASS
would be probably v.in.tiger based on OGR, but that is what 
we wanted to avoid and to have only one import module, see below.

> Ideally the OGR TIGER/Line driver should do this for you (at least
> optionally) but I have not implemented that.

I thought that OGR does this for all supported layers. What it does 
for ArcInfo coverage? But as I mentioned above, for GRASS, SFS polygon
is the problem not raw data. 
The best for GRASS would be if OGR could optionaly offer data in both
SFS and topological form, if available (Tiger, Coverage).
Otherwise OGR builds polygons from topology, v.in.ogr imports polygons
and v.clean must be used to split polygons and remove duplicates.


Radim




More information about the grass-user mailing list