[GRASS-user] v.to.rast with text column

Dylan Beaudette debeaudette at ucdavis.edu
Wed Oct 14 14:53:56 EDT 2009


Great! Thanks for the tips. I was able to accomplish this (in PostGresql) with 
the following steps:

1. generate unique list of text categories as a temp table
2. add a serial column to the temp table (auto-incrementing integer)
3. add new column to original table
4. UPDATE original table with the new serial number, assigned by text category
5. v.to.rast

Cheers,
Dylan


On Wednesday 14 October 2009, Markus Neteler wrote:
> IMHO ticket 175 has been fixed. I can now run (thanks to Martin):
>
> v.db.select lsat7_training
> cat|name|id
> 1|water|1
> 3|forest|2
> 4|forest|2
> 5|asphalt|3
> 6|asphalt|3
> 7|water|1
> ...
> v.to.rast in=lsat7_training out=lsat7_training use=attr col=id
> labelcol=name
>
> As Achim says: col must be numerical and should be the numerical
> representation of the text attributes (see example above).
>
> Markus
>
> On Wed, Oct 14, 2009 at 1:39 PM, Hamish <hamish_b at yahoo.com> wrote:
> > see also  https://trac.osgeo.org/grass/ticket/175
> >
> > Achim wrote:
> >> v.to.rast has the option:
> >>
> >> --%<--
> >> labelcolumn=name
> >>     Name of column used as raster category
> >> labels
> >> --%<--
> >>
> >> And the raster values have to be numeric:
> >>
> >> --%<--
> >> column=name
> >>     Name of column for attr parameter (data type
> >> must be numeric)
> >> --%<--
> >>
> >> (http://grass.itc.it/grass64/manuals/html64_user/v.to.rast.html)
> >>
> >> Try to make unique numbers from your string-column and
> >> convert them with
> >> column=... and labelcolumn...
> >>
> >> Achim
> >>
> >> Dylan Beaudette schrieb:
> >> > Hi,
> >> >
> >> > v.to.rast is letting me know that it does not accept
> >>
> >> text columns in an
> >>
> >> > attribute table. Has anyone figured out a simple
> >>
> >> approach to making this
> >>
> >> > work? I suppose that I could import the data into R,
> >>
> >> convert to factors, save
> >>
> >> > the levels back to the table and use those... but
> >>
> >> there may be something out
> >>
> >> > there that is simpler and can be done within GRASS.
> >>
> >> Also, would this be
> >>
> >> > something worth adding to the v.to.rast code?
> >> >
> >> > Cheers,
> >> > Dylan
> >
> > _______________________________________________
> > grass-user mailing list
> > grass-user at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/grass-user



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341


More information about the grass-user mailing list