[GRASS-user] populating dbtable with value sequence

Moritz Lennert mlennert at club.worldonline.be
Thu Apr 18 07:48:40 PDT 2013


On 18/04/13 15:52, Shaun Langley wrote:
> **This question is also posted on stackexchange.com
> <http://stackexchange.com>**
>
> I have a vector map that includes 100 points. These points were created
> using |v.extract| to randomly sample a larger map of 10k points. As
> such, the 'cat' values range from 1 to more than 10k. What I would like
> to do is to update the attribute table by rescaling these values to 1 to
> 100.
>
> Here's what I've experienced. If I use
>
> |v.category input=pts100 output=foo option=del
> v.category input=foo output=pts100 option=add --o|
>
> Then when the 'cat' values /appear/ rescaled when I print them with
>
> |v.category input=pts100 option=print|
>
> However, if I look at the dbtable with
>
> |db.select pts100|
>
> the 'cat' values have not changed (presumably because it is the key column).
>
> So I'm thinking I will need to add a new column using |v.db.addcol|, but
> I don't know how to specify the range of value to populate the new
> column. From what I can tell, I have to specify a single value.
>
> Ideas?

Either

- v.distance (possibly with dmax=0) to get the cat values from the new 
points into the old map and then v.reclass to use the new values as cat 
values.

or

- v.db.addcol YourOldMap col='newcat int'
- populate that column with values from 1 to 100
- v.reclass as above

It might be an idea to add to v.category the possibility to propagate 
cat value changes to the attribute table. You could file a wish on the 
bugtracker.

Moritz


More information about the grass-user mailing list