[Xastir-dev] TIGER/Line water polygons, or lack thereof

Tom Russo russo at bogodyn.org
Wed Oct 20 14:00:04 EDT 2004


On Tue, Oct 19, 2004 at 10:24:24PM -0700, we recorded a bogon-computron collision of the <archer at eskimo.com> flavor, containing:
> 
> I've been messing with the OGR driver quite a bit lately.  One of
> the formats it can read is TIGER/Line, but these files evidently
> have no representation of polygons in them, instead using polylines
> to represent the features.

It's not that there are no representations of polygons in the TIGER/Line data,
but that the representation isn't simple.

The data needed to get at polygons is scattered across several record types.
For each polygon, there's a record of type P ("Polygon Internal Point" or PIP) 
that defines an internal point in that polygon.  For each record of type P 
there is a record of type A ("Polygon Geographic Entity Codes: current 
geography") that defines entity codes (i.e. attributes). Additionally, for 
each record of type P there is a set of records of type I that identify the 
polylines (called "Complete Chain Basic Data" in TIGER parlance) that form its
boundaries. Type I records point to type 1 records, which contain end nodes 
for a complete chain, which might in turn have records of type 2 defining 
additional points on a polyline ("Complete Chain Shape Coordinates").

To draw filled polygons you'd have to loop through the type P records, then
for each one grab the type I records associated  with it.  Then you'd 
have to pull out the type 1 records and check whether there are type 2
records to go along with them.  You could then make a polygon by assembling
all the polylines from type 2 records (if there are any) and line segments
from any type 1 records that don't have associated type 2 records.

To fill them intelligently, you'd also need to pull out information from the 
type A and S records to determine what type of polygon you have and choose
a color.  To get names of polygons you have to follow a convoluted path 
to records of type C.

When converted to shapefiles with ogr2ogr, the tiger data gets farmed out
into a bunch of dbf and shp files.  I can guess at what they are:

  PIP.{shp,dbf,shx} are from type P records
  PolyChainLink.dbf is the type I records --- no associated shapefile, just a
                                              table
  CompleteChain.{dbf,shp,shx} --- these are the polylines from type 1 and 2 
                                  records, and apparently ogr has done 
                                  something intelligent with the
                                  A and C records, because the data from them
                                  somehow gets pulled togehther into the .dbf
                                  file
   Polygon.dbf                --- Not exactly sure what's there, but it
                                  might be the type S records.  A quick look
                                  with dbfinfo makes me wonder if these have
                                  somehow been combined with C records, too.
 
It might be the case when you load tiger data into xastir with ogr that
ogr "layers" of a similar name show up that you can manipulate until you 
get the right data in the right form for drawing.
 
> Can anyone shed some light on how I should attempt to draw filled
> water polygons from these?

Clear as mud?

Since it does seem that ogr knows enough about tiger structure that ogr2ogr
can assemble meaningful CompleteChain polyline files with appropriate 
attributes (i.e. it has merged information from several tables), perhaps
the best way to get tiger polygons is to push back on GDAL/OGR development
to do something similar with polygons.  All the data is there when the TIGER
data is read in by OGR, it just doesn't assemble the polygons so they're 
readily accessible for drawing quickly.  

-- 
Tom Russo    KM5VY     SAR502  DM64ux         http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236 AHTB#1 http://www.qsl.net/~km5vy/
(1) Ignorance of your profession is best concealed by solemnity and silence,
which pass for profound knowledge upon the generality of mankind.
                -------"Advice to Officers of the British Army", 1783



More information about the Xastir-dev mailing list