Hi,
I have a raster river (processed with r.thin) which I want to transfrom to a vector.
Therefore I use r.to.vect with the lines option. However, the raster has two different
values representing e.g. habitat quality (good/bad) for single segments (group of raster cells). This information is written strangely to the vector attribute table as the lines
are not broken at changes of habitat quality which is a reasonable behaviour of r.to.vect.
As I need the attributes in my vector table I thought about splitting the vector into
small segments (<raster resolution) and updating the attribute table with v.what.rast. However when I use v.split the attribute table of the created map still has the same number of entries than before. So what do I miss here to get single rows and thus categories for the single created lines from v.split?
Or is there any other/better way for such transformation of raster lines to vector lines incl. an update of the attribute table?
Best regards,
Johannes
On 27/01/14 11:27, Johannes Radinger wrote:
Hi,
I have a raster river (processed with r.thin) which I want to transfrom
to a vector.
Therefore I use r.to.vect with the lines option. However, the raster has
two different
values representing e.g. habitat quality (good/bad) for single segments
(group of raster cells). This information is written strangely to the
vector attribute table as the lines
are not broken at changes of habitat quality which is a reasonable
behaviour of r.to.vect.
As I need the attributes in my vector table I thought about splitting
the vector into
small segments (<raster resolution) and updating the attribute table
with v.what.rast. However when I use v.split the attribute table of the
created map still has the same number of entries than before. So what do
I miss here to get single rows and thus categories for the single
created lines from v.split?
Or is there any other/better way for such transformation of raster lines
to vector lines incl. an update of the attribute table?
I'm not sure I totally understand your problem (an example with the NC data would probably help), but have you tried the '-v' flag (Use raster values as categories instead of unique sequence) of r.to.vect ?
Moritz
Hi Moritz,
hi all,
sorry for my late response. I can now provide an example using the NC dataset.
First I needed to generate data (rasterized line/river) similar to the data input I am using.
So I transformed the streams vector into a raster using the attribute column FCODE as
value for the raster (v.to.rast input=streams@PERMANENT output=r_streams column=FCODE)
Thereafter I thinned the raster (r.thin input=r_streams@PERMANENT output=r_streams_thin). The
output corresponds to a map similar to my original map I am using.
Now I wanted to (back-)transform the raster map back to lines where the resulting line segments should
correspond to the segments visible in the raster map
(r.to.vect input=r_streams_thin@PERMANENT output=v_r_streams_thin feature=line). However, lines
are broken only where different lines join.
I attached a screenshot that illustrates my task. You can see the raster map with three
different segments (two different values) for that single tribuatry (indicated by blue-yellow-blow).
However when the raster gets transformed into a line this information gets lost, as lines
are not broken where a new raster value starts. Any suggestions how to solve such
a task?
cheers,
Johannes
(attachments)

···
On Tue, Jan 28, 2014 at 9:31 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:
On 27/01/14 11:27, Johannes Radinger wrote:
Hi,
I have a raster river (processed with r.thin) which I want to transfrom
to a vector.
Therefore I use r.to.vect with the lines option. However, the raster has
two different
values representing e.g. habitat quality (good/bad) for single segments
(group of raster cells). This information is written strangely to the
vector attribute table as the lines
are not broken at changes of habitat quality which is a reasonable
behaviour of r.to.vect.
As I need the attributes in my vector table I thought about splitting
the vector into
small segments (<raster resolution) and updating the attribute table
with v.what.rast. However when I use v.split the attribute table of the
created map still has the same number of entries than before. So what do
I miss here to get single rows and thus categories for the single
created lines from v.split?
Or is there any other/better way for such transformation of raster lines
to vector lines incl. an update of the attribute table?
I’m not sure I totally understand your problem (an example with the NC data would probably help), but have you tried the ‘-v’ flag (Use raster values as categories instead of unique sequence) of r.to.vect ?
Moritz
On 03/02/14 11:48, Johannes Radinger wrote:
Hi Moritz,
hi all,
sorry for my late response. I can now provide an example using the NC
dataset.
First I needed to generate data (rasterized line/river) similar to the
data input I am using.
So I transformed the streams vector into a raster using the attribute
column FCODE as
value for the raster (v.to.rast input=streams@PERMANENT output=r_streams
column=FCODE)
Thereafter I thinned the raster (r.thin input=r_streams@PERMANENT
output=r_streams_thin). The
output corresponds to a map similar to my original map I am using.
Now I wanted to (back-)transform the raster map back to lines where the
resulting line segments should
correspond to the segments visible in the raster map
(r.to.vect input=r_streams_thin@PERMANENT output=v_r_streams_thin
feature=line). However, lines
are broken only where different lines join.
I attached a screenshot that illustrates my task. You can see the raster
map with three
different segments (two different values) for that single tribuatry
(indicated by blue-yellow-blow).
However when the raster gets transformed into a line this information
gets lost, as lines
are not broken where a new raster value starts. Any suggestions how to
solve such
a task?
Same response as last time: try the -v flag of r.to.vect.
Moritz
I already tried the v-flag. This creates a attribute table with in this case 4 lines (corresponding to the 4 distinct FCODE values).
However there are more segments than just 4. There are e.g. multiple “segments” with the value 33400 in the entire region
which are maybe then joint into one category? When I try then to query the map with the query-tool nothing happens (no selection in yellow, no information). So the desired result should contain probably more than 100 segments of which some have the same value in an attribute column called FCODE. I don’t really know how the -v flag can help here?
/Johannes
···
On Mon, Feb 3, 2014 at 1:48 PM, Moritz Lennert <mlennert@club.worldonline.be> wrote:
On 03/02/14 11:48, Johannes Radinger wrote:
Hi Moritz,
hi all,
sorry for my late response. I can now provide an example using the NC
dataset.
First I needed to generate data (rasterized line/river) similar to the
data input I am using.
So I transformed the streams vector into a raster using the attribute
column FCODE as
value for the raster (v.to.rast input=streams@PERMANENT output=r_streams
column=FCODE)
Thereafter I thinned the raster (r.thin input=r_streams@PERMANENT
output=r_streams_thin). The
output corresponds to a map similar to my original map I am using.
Now I wanted to (back-)transform the raster map back to lines where the
resulting line segments should
correspond to the segments visible in the raster map
(r.to.vect input=r_streams_thin@PERMANENT output=v_r_streams_thin
feature=line). However, lines
are broken only where different lines join.
I attached a screenshot that illustrates my task. You can see the raster
map with three
different segments (two different values) for that single tribuatry
(indicated by blue-yellow-blow).
However when the raster gets transformed into a line this information
gets lost, as lines
are not broken where a new raster value starts. Any suggestions how to
solve such
a task?
Same response as last time: try the -v flag of r.to.vect.
Moritz