[GRASS-user] Buffered categories

Hi,

I feel like I'm being thick, but ...

v.buffer creates a map in which all centroids are assigned the same category value (ie, 1). How do I assign a unique category value to all centroids?

Richard Chirgwin

On 23/02/12 09:24, Richard Chirgwin wrote:

Hi,

I feel like I'm being thick, but ...

v.buffer creates a map in which all centroids are assigned the same
category value (ie, 1). How do I assign a unique category value to all
centroids?

If you just want to assign any values: v.category.

If you create buffers around points which have category values and you would like to assign those values to the buffers, you can then (after v.category) do something like this:

v.db.addtable yourbuffers
v.db.addcol yourbuffers col="pointcat int"
v.distance from=yourbuffers to=yourpoints dmax=0 upload=cat column=pointcat

Moritz

Moritz wrote:

If you create buffers around points which have category
values and you would like to assign those values to the buffers,
you can then (after v.category) do something like this:

v.db.addtable yourbuffers
v.db.addcol yourbuffers col="pointcat int"
v.distance from=yourbuffers to=yourpoints dmax=0
upload=cat column=pointcat

except of course if two of those buffers overlap, in which case it is
ambiguous as to which starting category the merged buffer area should
take. (which is why v.buffer just assigns everything to category 1 instead
of preserving seed categories in the first place)

Hamish

On Thu, Feb 23, 2012 at 8:14 PM, Hamish <hamish_b@yahoo.com> wrote:

Moritz wrote:

If you create buffers around points which have category
values and you would like to assign those values to the buffers,
you can then (after v.category) do something like this:

v.db.addtable yourbuffers
v.db.addcol yourbuffers col="pointcat int"
v.distance from=yourbuffers to=yourpoints dmax=0
upload=cat column=pointcat

except of course if two of those buffers overlap, in which case it is
ambiguous as to which starting category the merged buffer area should
take. (which is why v.buffer just assigns everything to category 1 instead
of preserving seed categories in the first place)

Preserving seed categories is in theory easy, no need to assign new
category 1 to all new areas. In ambiguous cases, you could assign all
seed categories to the merged buffer area.

Markus M

Markus, Moritz and Hamish -

Thanks all; some responses.

On 24/02/12 7:40 AM, Markus Metz wrote:

On Thu, Feb 23, 2012 at 8:14 PM, Hamish<hamish_b@yahoo.com> wrote:

Moritz wrote:

If you create buffers around points which have category
values and you would like to assign those values to the buffers,
you can then (after v.category) do something like this:

v.db.addtable yourbuffers
v.db.addcol yourbuffers col="pointcat int"
v.distance from=yourbuffers to=yourpoints dmax=0
upload=cat column=pointcat

Moritz - the problem is that if the buffers are assigned a single cat to all their centroids (even when non-overlapping), there is only one cat value, and v.distance can't update.

Hence: v.db.select yourbuffers produces:
cat
1

rather than the 47 categories I need (because there are 47 distinct areas in the buffer.

So: how do I reassign the cats so there are 47 instead of 1 in the buffer?

Cheers,
Richard

except of course if two of those buffers overlap, in which case it is
ambiguous as to which starting category the merged buffer area should
take. (which is why v.buffer just assigns everything to category 1 instead
of preserving seed categories in the first place)

Preserving seed categories is in theory easy, no need to assign new
category 1 to all new areas. In ambiguous cases, you could assign all
seed categories to the merged buffer area.

Markus M

Richard wrote:

rather than the 47 categories I need (because there are 47
distinct areas in the buffer.

So: how do I reassign the cats so there are 47 instead of 1
in the buffer?

# get rid of the old
v.category type=centroid op=del
# create some new sequential ones
v.category type=centroid op=add cat=1 step=1

(cat= is the number it starts counting from)

if you need the cat to match the seed point, use v.distance as earlier
suggested. and do beware of what becomes of overlapping areas.

Hamish

<headdesk>

Thanks!

The handling of overlapping areas is the reason I keep recompiling the older version of v.buffer as v.oldbuffer. This lets me use the old debug flag to prevent it from cleaning the areas, which I can then turn into discrete areas instead of having them combined by the newer version. Which reminds me, since the latest upgrade ...

RC

On 24/02/12 7:30 PM, Hamish wrote:

Richard wrote:

rather than the 47 categories I need (because there are 47
distinct areas in the buffer.

So: how do I reassign the cats so there are 47 instead of 1
in the buffer?

# get rid of the old
v.category type=centroid op=del
# create some new sequential ones
v.category type=centroid op=add cat=1 step=1

(cat= is the number it starts counting from)

if you need the cat to match the seed point, use v.distance as earlier
suggested. and do beware of what becomes of overlapping areas.

Hamish

As always, thanks to everyone for helping fix even simple errors!

Richard

On 24/02/12 7:30 PM, Hamish wrote:

Richard wrote:

rather than the 47 categories I need (because there are 47
distinct areas in the buffer.

So: how do I reassign the cats so there are 47 instead of 1
in the buffer?

# get rid of the old
v.category type=centroid op=del
# create some new sequential ones
v.category type=centroid op=add cat=1 step=1

(cat= is the number it starts counting from)

if you need the cat to match the seed point, use v.distance as earlier
suggested. and do beware of what becomes of overlapping areas.

Hamish