[GRASS-user] occurrence of attributes in vektortable

Marco Lechner marco.lechner at geographie.uni-freiburg.de
Sun Mar 9 09:48:33 EDT 2008


piping to "cut" and "sort", does the job as i wanted - thanks (just 
didn't know about the unique-switch in sort. Great!

  | cut -d "|" -f3 | sort -u"


Marco

Nikos Alexandris schrieb:
> On Fri, 2008-03-07 at 11:37 +0100, Marco Lechner wrote:
>> hi list,
>>
>> how can i get a list of all different occurences in a column of an 
>> attributetable.
> 
> Marco,
> 
> in a linux-box another way would be to combine db.select with the "sort"
> command.
> 
> Example (commands in quotes):
> 
> I have a table TrainingSamples which looks like:
> 
> "v.info -c TrainingSamples"
> Displaying column types/names for database connection of layer 1:
> INTEGER|cat
> INTEGER|clccode_le
> TEXT|label
> 
> 
> "db.selct TrainingSamples"
> 1|3|vegetation
> 2|334|Burned
> 3|334|Burned
> 
> [...]
> 
> 45|332|non_veg
> 46|2|agro
> 
> And I want to get only the number of different  labels (in column
> "label")
> 
> "db.select TrainingSamples | cut -d "|" -f3 | sort -u"
> agro
> Burned
> label
> minext
> non_veg
> non_vegetation
> urban
> vegetation
> water
> 
> 
> ---
> * cut -d "|" splits an output line in more fields separated by the "|"
> character
> * -f3 (belongs to the cut command as well) and prints only the 3rd field
> * sort -u does the actual job. It prints only once a name/ number  no
> matter how many times it appears.
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: marco_lechner.vcf
Type: text/x-vcard
Size: 325 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20080309/a9d4c0fc/marco_lechner.vcf


More information about the grass-user mailing list