[GRASS-user] v.to.rast layer parameter

Neil Best nbest at forestone.com
Wed Mar 7 16:55:20 EST 2007


I am trying to use v.to.rast after connecting a table to a vector layer. 
  My intention was to connect multiple tables on different layers using 
meaningful integers (years) so that I could parameterize the creation of 
a slew of rasters based on the layer parameter and the columns in the 
individual tables.  I keep getting a null raster so when I noticed the 
note in the BUGS section of the v.to.rast man page I decided it was time 
to drop a line.

Here is my basic process:

v.in.ogr
   dsn="PG:host=foo dbname=bar"\
   output="my_vect" layer="source_vect"\
   min_area=0.0001 type="boundary,centroid" snap=-1

db.copy\
   from_driver=pg from_database="host=foo,dbname=bar"\
   from_table=source_table\
   to_driver=pg to_database="host=bodhi,dbname=f1_hbu"\
   to_table=table_1982\
   where="year=1982"

v.db.connect\
   map=my_vect\
   driver=pg database="host=foo,dbname=bar"\
   table=table_1982\
   key=some_col layer=1982

g.region vect=my_vect align=ref_grid

v.to.rast\
   input=my_vect\
   output=my_rast_1982\
   use="attr" column="percent" layer=1982

Even if I connect my source data to layer 1 I get an empty raster.  I 
can rasterize the attributes that come over with v.in.ogr just fine so 
it must have something to do with the v.db.connect'ion.  I can see the 
values with db.execute . . .  Am I doing something wrong?  I expect that 
the key value will join based on an attribute in layer 1 and my new 
layer on columns by the same name -- is that how it works?  I can't be 
sure becuase d.what.vect won't show me those attributes.

I took this approach after finding that I could not run v.in.ogr against 
PostGIS views even though they are properly registered in 
geometry_columns and so forth -- I can see my views just fine in QGIS, 
so I came up with this workaround to join attributes to geometries on 
the GRASS side. Any insight on either front would be appreciated.

Should I send this to the developers' list?





More information about the grass-user mailing list