[GRASSLIST:611] Re: How do I create a thematic map from a shapefile?

Jesse Hamner jhamner at emory.edu
Thu Apr 6 17:13:37 EDT 2006


On Apr 6, 2006, at 4:15 PM, Jesse Hamner wrote:

> If the basin dbf has no attributes, you'll have to add your basin  
> ID to the vector coverage first, and then you can merge the  
> rainfall values with db.execute (or do it outside of GRASS using,  
> say, MySQL).
>
> First add a column in the database for your unique ID. I'd use  
> db.execute here too, or else do it outside of GRASS in a terminal  
> window.
>
> To add basin IDs, use the d.what.vect -ef command, clicking through  
> each basin and assigning the appropriate value to the "BASIN_ID"  
> column.
>
> Last, as noted above, you can then (in MySQL, at least) Left- or  
> Right-JOIN the tables WHERE index.table1 = index.table2. This type  
> of JOIN has the added bonus of filling in missing values with NULL,  
> so you can spot values you might have skipped.
>
> Alternately, you could create a "RAINFALL" field in your coverage  
> dbf file (here, I'll call it 'tablename') and use
>
> UPDATE tablename SET 'tablename.RAINFALL'= 'othertable.rainfall'  
> WHERE 'tablename.BASIN_ID' = 'othertable.basin_id';
>
> to merge in the one value; I think that's the right syntax-- 
> somebody tell me if I screwed up.

I should note that these SQL commands won't work with the dbf driver-- 
you'll have to db.connect to a mysql database and db.copy your  
polygon attribute table into the database. Allen Hollander's solution  
will work with the dbf driver, so that's a consideration.

Jesse




More information about the grass-user mailing list