[GRASS-user] Associating attributes from Postgres file with a key other than cat

Hamish hamish_nospam at yahoo.com
Mon Aug 13 23:02:57 EDT 2007


Turner, James wrote:
> > I have the Census ZCTA data loaded up "locally" (not in a database),
> > and some proprietary zip-code based data in a Postgres DB table. 
> > The Postgres data is keyed off the zip code, and obviously knows
> > nothing about the cat #s of the imported e00 file with the ZCTA
> > data.  Is there any non-trivial way to make the values in the
> > Postgres table available to GRASS so that I can use it to do
> > coloring of areas, etc.
..
> That would work if there was an equivalent to the CAT field in the
> table I wanted to join to.  There isn't, it needs to join on the zip
> code, which is the key field for the data in Postgres.  There doesn't
> seem to be any way to associate data from an SQL table to a piece of
> vector data unless the SQL table has the same cat field available.  In
> other words, if the original imported e00 file has:
> 
> cat
> zipcode
> altitude
> population
> 
> and the database table has:
> 
> zipcode
> median_income
> life_expectancy
> 
> There's no way to get the two associated on the basis of the common
> zipcode field.  The only solution I was able to find was to db.copy
> the e00 data to the Postgres database, add a cat field to the existing
> table, and then use a query to fill the cat fields in by doing a join.


Try the v.reclass column= option to set the integer zipcode column to be
the cat index instead of the CAT column. If you want, add a new
sequential integer column for cat with v.db.addcol + v.category.



Hamish




More information about the grass-user mailing list