[GRASS-user] v.to.rast, r.to.vect, "stable" transformation

Hello,

as it seems that there was something wrong with my post yesterday I send it
again (if everything was ok already yesterday, sorry for double posting):

For a certain application I need to transform a river from the
raster format into the vector format and vice versa.

I'd like to know how good does it work to tranform a line
feature from vector into raster and back again into
a vector? Is there any "stable" line which doesn't
change anymore after x-times transforming back and
forwards? I haven't had time to test it but I thought about:

v.to.rast
r.thin
r.to.vect

this should result in a "stable" line or does it
need several iterations?

Has anyone tested such things and can share the experience?

Probably it depends on the resolution and the
shape (bends etc.) of the line vector...

Maybe there is already a tool out which generalises, produces
and tests a "stable" raster-vector-line.

Any hints and suggestions are mostly welcome...

best regards,
Johannes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 26/01/12 10:29, Johannes Radinger wrote:

Hello,

as it seems that there was something wrong with my post yesterday
I send it again (if everything was ok already yesterday, sorry for
double posting):

Your post went through - but some mail readers don't show your own
posts, and some mailing lists don't send you your own posts...

So what i usually do when checking, I go into google and search for
the topic of my post - if it was posted, it will show up in e.g. gmane
or any other site. If it does not (within a few hours) you can assume
that it did not went through and post it again.

Sorry - no idea about your question.

Cheers,

Rainer

For a certain application I need to transform a river from the
raster format into the vector format and vice versa.

I'd like to know how good does it work to tranform a line feature
from vector into raster and back again into a vector? Is there any
"stable" line which doesn't change anymore after x-times
transforming back and forwards? I haven't had time to test it but
I thought about:

v.to.rast r.thin r.to.vect

this should result in a "stable" line or does it need several
iterations?

Has anyone tested such things and can share the experience?

Probably it depends on the resolution and the shape (bends etc.)
of the line vector...

Maybe there is already a tool out which generalises, produces and
tests a "stable" raster-vector-line.

Any hints and suggestions are mostly welcome...

best regards, Johannes

_______________________________________________ grass-user mailing
list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44

Fax (D): +49 - (0)3 21 21 25 22 44

email: Rainer@krugs.de

Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8hJJEACgkQoYgNqgF2egoM8QCfYe+yYNj2QRbU+Ac4Pr+q/pTi
CXkAnj7MXdF7Pp5r9O6DR9znpiKdHhnE
=WYHT
-----END PGP SIGNATURE-----

On 26/01/12 10:29, Johannes Radinger wrote:

Hello,

as it seems that there was something wrong with my post yesterday I send it
again (if everything was ok already yesterday, sorry for double posting):

For a certain application I need to transform a river from the
raster format into the vector format and vice versa.

I'd like to know how good does it work to tranform a line
feature from vector into raster and back again into
a vector? Is there any "stable" line which doesn't
change anymore after x-times transforming back and
forwards? I haven't had time to test it but I thought about:

v.to.rast
r.thin
r.to.vect

this should result in a "stable" line or does it
need several iterations?

I think the best way is to try, but some remarks here:

- I don't think that r.thin avec v.to.rast will change anything. v.to.rast should already limit the raster version of the line to a widthof one pixel.

- The main issue here will probably be the resolution.

- To test, just try running v.to.rast/r.to.vect several times in a loop and then compare the end result to the original river...

Moritz

Hi again,

On 26/01/12 10:29, Johannes Radinger wrote:
> Hello,
>
> as it seems that there was something wrong with my post yesterday I send
it
> again (if everything was ok already yesterday, sorry for double
posting):
>
>
> For a certain application I need to transform a river from the
> raster format into the vector format and vice versa.
>
> I'd like to know how good does it work to tranform a line
> feature from vector into raster and back again into
> a vector? Is there any "stable" line which doesn't
> change anymore after x-times transforming back and
> forwards? I haven't had time to test it but I thought about:
>
> v.to.rast
> r.thin
> r.to.vect
>
> this should result in a "stable" line or does it
> need several iterations?

I think the best way is to try, but some remarks here:

- I don't think that r.thin avec v.to.rast will change anything.
v.to.rast should already limit the raster version of the line to a
widthof one pixel.

- The main issue here will probably be the resolution.

- To test, just try running v.to.rast/r.to.vect several times in a loop
and then compare the end result to the original river...

I tried it to run v.to.rast/r.thin/r.to.vect... I am not sure but it seems
that already the first run creates a "stable" vector as the the vector is just the connection of the midpoints of the cells (so only a limited number of vector directions: horizontal, vertical, diagonal). So far as I think this must be a stable vector....

The r.thin process is an important step (as recommended also in the manual) and should not be skipped at all! And so far as I think now it isn't an issue of the resolution as it is always the procedure of reconnecting the cell-midpoints...

Maybe I just see something wrong..anyway i thought about testing the stability in a loop, but I got stucked in the correct map calc operation.
What is the correct (boolean) operator to get:
1) NULL + NULL = NULL
2) not NULL + not NULL = NULL
3) not NULL + NULL = 1
4) NULL + not NULL = 1

this is just to find out if the two rasters are congruent (of the same shape).

Maybe anyone has some suggestions...

best regards,

Johannes

Moritz
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://www.gmx.net/de/go/freephone/

On 06/02/12 12:46, Johannes Radinger wrote:

The r.thin process is an important step (as recommended also in the
manual) and should not be skipped at all!

In general, I agree with you, but I'm not sure that v.to.rast + r.to.vect would profit of r.thin in the middle, since v.to.rast already should provide a thinned line. AFAIU r.thin is useful when you have raster lines produced by something else than v.to.rast.

Maybe I just see something wrong..anyway i thought about testing the
stability in a loop, but I got stucked in the correct map calc
operation. What is the correct (boolean) operator to get:

>

1) NULL + NULL = NULL

> 2) not NULL + not NULL = NULL
> 3) not NULL + NULL = 1

4) NULL + not NULL = 1

How about (untested):

if( (isnull(A) && isnull(B)) || (!isnull(A) && !isnull(B)), null(), 1)

Moritz

Hi,

-------- Original-Nachricht --------

Datum: Mon, 06 Feb 2012 13:31:10 +0100
Von: Moritz Lennert <mlennert@club.worldonline.be>
An: Johannes Radinger <JRadinger@gmx.at>
CC: grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] v.to.rast, r.to.vect, "stable" transformation

On 06/02/12 12:46, Johannes Radinger wrote:
> The r.thin process is an important step (as recommended also in the
> manual) and should not be skipped at all!

In general, I agree with you, but I'm not sure that v.to.rast +
r.to.vect would profit of r.thin in the middle, since v.to.rast already
should provide a thinned line. AFAIU r.thin is useful when you have
raster lines produced by something else than v.to.rast.

I can only speak from what I've tested so far: I transformed a river vector (including meanders and confluences etc.) into a raster. And due to the bends in some cases the river is not a thinned line. Therefore r.thin is necessary in my case also for a v.to.raster- line.

> Maybe I just see something wrong..anyway i thought about testing the
> stability in a loop, but I got stucked in the correct map calc
> operation. What is the correct (boolean) operator to get:
>
> 1) NULL + NULL = NULL
> 2) not NULL + not NULL = NULL
> 3) not NULL + NULL = 1
> 4) NULL + not NULL = 1

How about (untested):

if( (isnull(A) && isnull(B)) || (!isnull(A) && !isnull(B)), null(), 1)

Thank you I'll try that, I just thought that there might be a simple operator (as I am not that familiar with boolean operators).

/Johannes

Moritz

--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://www.gmx.net/de/go/freephone/

Johannes Radinger wrote:

Maybe I just see something wrong..anyway i thought about testing the
stability in a loop, but I got stucked in the correct map calc
operation.

What is the correct (boolean) operator to get:
1) NULL + NULL = NULL
2) not NULL + not NULL = NULL
3) not NULL + NULL = 1
4) NULL + not NULL = 1

  if(isnull(A) == isnull(B),null(),1)

--
Glynn Clements <glynn@gclements.plus.com>