[Xastir-dev] TIGER/Line water polygons, or lack thereof
Tom Russo
russo at bogodyn.org
Wed Oct 20 14:46:27 EDT 2004
On Wed, Oct 20, 2004 at 12:00:04PM -0600, we recorded a bogon-computron collision of the <russo at bogodyn.org> flavor, containing:
> 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
Nope, I'm wrong about this. On closer inspection, CompleteChain contains only
information from type 1 and type 2 records. These records have things like
the names of features already. Coupling to the type C records isn't needed.
> 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.
Nope. Looking at ogr source code, they're combining info from type A and S
records, which apparently contain entity names without needing to
cross-reference to type C records.
I'm looking at the TIGER 2003 technical documentation to get at all this,
occasionally digging into ogr source code.
The relevant polygon/chain linkage records (type I) have a field TLID that
gives a complete chain id number (to be matched with a type 1 record), and
a PAIR of fields (POLYIDL and POLYIDR) giving the IDs (to be linked with type P
records) of the polygons on the right and left of the line, as if standing
at the start of the polyline and facing the endpoint. So to draw polygons you'd
need to:
loop over all type P records (PIP), set polyid to the POLYID field
Find all type I records that have that have polyid in POLYIDL *or* POLYIDR
(these are polylines that are part of the boundary of POLYID)
Using the TLID in the type I record, find the corresponding type 1 record
(This gives the end nodes of the polyline)
The first point of the type 1 record is a polygon vertex
(latitude FRLAT, longitude FRLONG)
Find all type 2 records with the same TLID
If one exists, it contains up to 10 additional polygon vertices
(if not, the polyline is just two points)
The second point of the type 1 record is the last polygon vertex
from this particular polyline (lat TOLAT, long TOLONG)
Draw the polygon using the set of vertices assembled that way
Ick. Actually, since you're using OGR, ogr's already taken care of assembling
the complete chains into a "layer" called CompleteChain. So the inner loop is
already taken care of, and you'd just need to use TLID from the type I record
to select a polyline from CompleteChain to get the vertices. You'd still
need to do the loop over type I records (PolyChainLink) to get all polylines
that have the chosen polygon in POLYIDL or POLYIDR.
You also have to pull polygon attributes from other tables (Polygon).
--
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/
"The truth will set you free, but first it will piss you off."
More information about the Xastir-dev
mailing list