[GRASS-dev] v.to.db option=slope

Hallo,
somebody asked on IRC, how to calculate slopes for vector lines.

This patch should add new option "slope" to v.to.db module and calculate slope steepness
for each vector line

What do you think, shall I commit this patch to cvs?

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

(attachments)

v.to.db-slope.patch (6.59 KB)

On Thu, Dec 07, 2006 at 05:30:00PM +0100, Jachym Cepicky wrote:

Hallo,
somebody asked on IRC, how to calculate slopes for vector lines.

This patch should add new option "slope" to v.to.db module and calculate slope steepness
for each vector line

What do you think, shall I commit this patch to cvs?

Hi Jachym,

nice idea! Without inspecting the patch, does it work in LatLong?

Markus

Interesting patch Jachym!

Out of curiosity, and not being able to extract it from the patch, how
exactly does this approach work? Are you caclulating a slope between
vertices of a 3D vector?

Looking forward to learning more about it!

Great job,

Dylan

On 12/7/06, Jachym Cepicky <jachym.cepicky@centrum.cz> wrote:

Hallo,
somebody asked on IRC, how to calculate slopes for vector lines.

This patch should add new option "slope" to v.to.db module and calculate slope steepness
for each vector line

What do you think, shall I commit this patch to cvs?

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFFeEGIyKt0uAjU4I8RAnlMAJ0R7J0aHMDAQ9rLIO9Ch3tJw03UTwCgomsY
wa4JKzCgM8UPheYO55p3fA4=
=F/eE
-----END PGP SIGNATURE-----

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

hi,
On Thu, Dec 07, 2006 at 05:43:23PM +0100, Markus Neteler wrote:

On Thu, Dec 07, 2006 at 05:30:00PM +0100, Jachym Cepicky wrote:
> Hallo,
> somebody asked on IRC, how to calculate slopes for vector lines.
>
> This patch should add new option "slope" to v.to.db module and calculate slope steepness
> for each vector line
>
> What do you think, shall I commit this patch to cvs?
>

Hi Jachym,

nice idea! Without inspecting the patch, does it work in LatLong?

Markus

no, it does not :frowning: it does not even work with option=length, because of

Vect_cidx_get_num_unique_cats_by_index ( &Map, Vect_cidx_get_field_index(&Map, options.field ) );

in main.c returns 1634887471 of unique cats by index and v.to.db ends up
with G_calloc error: could not allocat memory.

I have no clue, how to fix this bug.

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

hi,
On Thu, Dec 07, 2006 at 08:48:11AM -0800, Dylan Beaudette wrote:

Interesting patch Jachym!

Out of curiosity, and not being able to extract it from the patch, how
exactly does this approach work? Are you caclulating a slope between
vertices of a 3D vector?

it works very simply:
    (z_end - z_start)/length2d

so you get _approximated_ slope for whole line. e.g.

+ +
\ /
  \ /
   `---ยด

would result into slope=0

Looking forward to learning more about it!

Great job,

just a small patch :wink:

Dylan

thanks

jachym

On 12/7/06, Jachym Cepicky <jachym.cepicky@centrum.cz> wrote:
>Hallo,
>somebody asked on IRC, how to calculate slopes for vector lines.
>
>This patch should add new option "slope" to v.to.db module and calculate
>slope steepness
>for each vector line
>
>What do you think, shall I commit this patch to cvs?
>
>Jachym
>--
>Jachym Cepicky
>e-mail: jachym.cepicky@centrum.cz
>URL: http://les-ejk.cz
>GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
>-----------------------------------------
>OFFICE:
>Department of Geoinformation Technologies
>Zemedelska 3
>613 00, Brno
>Czech Republick
>e-mail: xcepicky@node.mendelu.cz
>URL: http://mapserver.mendelu.cz
>Tel.: +420 545 134 514
>
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.3 (GNU/Linux)
>
>iD8DBQFFeEGIyKt0uAjU4I8RAnlMAJ0R7J0aHMDAQ9rLIO9Ch3tJw03UTwCgomsY
>wa4JKzCgM8UPheYO55p3fA4=
>=F/eE
>-----END PGP SIGNATURE-----
>
>
>_______________________________________________
>grass-dev mailing list
>grass-dev@grass.itc.it
>http://grass.itc.it/mailman/listinfo/grass-dev
>
>
>

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

hi,

since nobody really complained, I commited the patch. v.to.db has new
option "slope" now

jachym

On Thu, Dec 07, 2006 at 05:30:00PM +0100, Jachym Cepicky wrote:

Hallo,
somebody asked on IRC, how to calculate slopes for vector lines.

This patch should add new option "slope" to v.to.db module and calculate slope steepness
for each vector line

What do you think, shall I commit this patch to cvs?

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

Index: vector/v.to.db/global.h

RCS file: /grassrepository/grass6/vector/v.to.db/global.h,v
retrieving revision 1.8
diff -u -r1.8 global.h
--- vector/v.to.db/global.h 9 Feb 2006 03:09:07 -0000 1.8
+++ vector/v.to.db/global.h 7 Dec 2006 16:21:18 -0000
@@ -13,7 +13,7 @@
                             /* for sides set to 2, if more than 1 area category was found, */
                             /* including no category (cat = -1)! */
     int i1,i2; /* values; i1: query (result int), sides; i2: sides */
- double d1,d2,d3; /* values (length, area, x/y/z, query) */
+ double d1,d2,d3,d4; /* values (length, area, x/y/z, query, slope) */
     char *str1; /* string value (query) */
     int *qcat; /* array query categories */
     int nqcats; /* number of query cats */
@@ -65,6 +65,8 @@

#define O_START 10 /* line/boundary starting point */
#define O_END 11 /* line/boundary end point */
+
+#define O_SLOPE 12 /* Line slope */

#define U_ACRES 1
#define U_HECTARES 2
Index: vector/v.to.db/lines.c

RCS file: /grassrepository/grass6/vector/v.to.db/lines.c,v
retrieving revision 1.8
diff -u -r1.8 lines.c
--- vector/v.to.db/lines.c 9 Feb 2006 03:09:07 -0000 1.8
+++ vector/v.to.db/lines.c 7 Dec 2006 16:21:18 -0000
@@ -48,7 +48,7 @@

/*
  * Read: - points/centroids : cat,count,coor
- * - lines/boundaries : cat,count,length
+ * - lines/boundaries : cat,count,length,slope
  */

int
@@ -58,7 +58,7 @@
     register int line_num;
     struct line_pnts *Points;
     struct line_cats *Cats, *LCats, *RCats;
- double len;
+ double len,slope;

     /* Initialize the Point struct */
     Points = Vect_new_line_struct();
@@ -137,7 +137,13 @@
         
                     read_side_cats ( LCats, &(Values[idx].i1), &(Values[idx].count1) );
                     read_side_cats ( RCats, &(Values[idx].i2), &(Values[idx].count2) );
+ } else if ( options.option == O_SLOPE && (type & GV_LINES) ) {
+ /* Calculate line slope */
+ len = length (Points->n_points, Points->x, Points->y);
+ slope = (Points->z[Points->n_points-1] - Points->z[0])/len;
+ Values[idx].d1 += slope;
     }
+
     found = 1;
       }
   }
@@ -167,7 +173,13 @@
       } else if ( options.option == O_SIDES && type == GV_BOUNDARY ) {
     read_side_cats ( LCats, &(Values[idx].i1), &(Values[idx].count1) );
     read_side_cats ( RCats, &(Values[idx].i2), &(Values[idx].count2) );
- }
+ } else if ( options.option == O_SLOPE && (type & GV_LINES) ) {
+ /* Calculate line slope */
+ len = length (Points->n_points, Points->x, Points->y);
+ slope = (Points->z[Points->n_points-1] - Points->z[0])/len;
+ Values[idx].d1 += slope;
+ }
+
   }
     }

Index: vector/v.to.db/parse.c

RCS file: /grassrepository/grass6/vector/v.to.db/parse.c,v
retrieving revision 1.19
diff -u -r1.19 parse.c
--- vector/v.to.db/parse.c 21 Sep 2006 12:50:39 -0000 1.19
+++ vector/v.to.db/parse.c 7 Dec 2006 16:21:18 -0000
@@ -48,7 +48,7 @@
     parms.option->type = TYPE_STRING;
     parms.option->required = YES;
     parms.option->multiple = NO;
- parms.option->options = "cat,area,compact,perimeter,length,count,coor,start,end,sides,query";
+ parms.option->options = "cat,area,compact,perimeter,length,count,coor,start,end,sides,query,slope";
     parms.option->description = _("Value to upload");
     parms.option->descriptions =
      "cat;insert new row for each category if doesn't exist yet;"
@@ -64,7 +64,8 @@
      "sides;categories of areas on the left and right side of the boundary, "
            "'qlayer' is used for area category;"
      "query;result of a database query for all records of the geometry"
- "(or geometries) from table specified by 'qlayer' option";
+ "(or geometries) from table specified by 'qlayer' option;"
+ "slope;slope steepness of vector line or boundary";

     parms.units = G_define_option();
     parms.units->key = "units";
@@ -100,7 +101,7 @@
     
     flags.t = G_define_flag();
     flags.t->key = 'c';
- flags.t->description = _("In print mode prints totals for options: length,area,count");
+ flags.t->description = _("In print mode prints totals for options: length,area");

     if (G_parser(argc,argv)) exit(EXIT_FAILURE);

@@ -132,7 +133,7 @@
     }
     
     if ( options.option == O_AREA || options.option == O_LENGTH || options.option == O_COUNT
- || options.option == O_QUERY || options.option == O_COMPACT || options.option == O_PERIMETER) /* one column required */
+ || options.option == O_QUERY || options.option == O_COMPACT || options.option == O_PERIMETER || options.option == O_SLOPE ) /* one column required */
     {
   if ( ncols != 1 ) {
       G_fatal_error ( _("This option requires one column") );
@@ -187,6 +188,7 @@
     else if (strcmp (s, "query") == 0) x = O_QUERY;
     else if (strcmp (s, "compact") == 0) x = O_COMPACT;
     else if (strcmp (s, "perimeter") == 0) x = O_PERIMETER;
+ else if (strcmp (s, "slope") == 0) x = O_SLOPE;

     return x;
}
Index: vector/v.to.db/report.c

RCS file: /grassrepository/grass6/vector/v.to.db/report.c,v
retrieving revision 1.11
diff -u -r1.11 report.c
--- vector/v.to.db/report.c 9 Feb 2006 03:09:07 -0000 1.11
+++ vector/v.to.db/report.c 7 Dec 2006 16:21:18 -0000
@@ -66,6 +66,13 @@
     for ( i = 0; i < vstat.rcat; i++ )
         fprintf (stdout, "%d|%.15g\n", Values[i].cat, Values[i].d1);
       }
+ break;
+ case O_SLOPE:
+ fprintf (stdout,"cat|slope\n");
+ for ( i = 0; i < vstat.rcat; i++ )
+ fprintf (stdout, "%d|%.15g\n", Values[i].cat, Values[i].d1);
+
+
             break;

         case O_COOR:
Index: vector/v.to.db/update.c

RCS file: /grassrepository/grass6/vector/v.to.db/update.c,v
retrieving revision 1.17
diff -u -r1.17 update.c
--- vector/v.to.db/update.c 9 Feb 2006 03:09:07 -0000 1.17
+++ vector/v.to.db/update.c 7 Dec 2006 16:21:18 -0000
@@ -49,6 +49,7 @@
   case O_QUERY:
   case O_COMPACT:
   case O_PERIMETER:
+ case O_SLOPE:
       sprintf (buf1, "update %s set %s =", Fi->table, options.col[0]);
             break;
         case O_COOR:
@@ -79,6 +80,7 @@
       case O_AREA:
       case O_COMPACT:
       case O_PERIMETER:
+ case O_SLOPE:
         sprintf (buf2, "%s %f where %s = %d", buf1, Values[i].d1, Fi->key, Values[i].cat);
           break;

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:

hi,

since nobody really complained, I commited the patch. v.to.db has new
option "slope" now

hi jachym,

does it now work for LatLong? I guess I overlooked some email.

Markus

hi Markus,

On Mon, Dec 11, 2006 at 06:58:36PM +0100, Markus Neteler wrote:

On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:
> hi,
>
> since nobody really complained, I commited the patch. v.to.db has new
> option "slope" now

hi jachym,

does it now work for LatLong? I guess I overlooked some email.

Markus

yes, I was writing about this:

no, it does not :frowning: it does not even work with option=length, because of

Vect_cidx_get_num_unique_cats_by_index ( &Map,
Vect_cidx_get_field_index(&Map, options.field ) );

in main.c returns 1634887471 of unique cats by index and v.to.db ends up
with G_calloc error: could not allocat memory.

I have no clue, how to fix this bug.

Jachym

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

Hello Jachym
Just a little comment below:

On Mon, 11 Dec 2006, Jachym Cepicky wrote:

On Mon, Dec 11, 2006 at 06:58:36PM +0100, Markus Neteler wrote:

On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:

hi,

since nobody really complained, I commited the patch. v.to.db has new
option "slope" now

hi jachym,

does it now work for LatLong? I guess I overlooked some email.

[...]

no, it does not :frowning: it does not even work with option=length, because of

Vect_cidx_get_num_unique_cats_by_index ( &Map,
Vect_cidx_get_field_index(&Map, options.field ) );

in main.c returns 1634887471 of unique cats by index and v.to.db ends up
with G_calloc error: could not allocat memory.

I have no clue, how to fix this bug.

I (maybe others) interpreted this as you admitting that the patch was not yet ready/good enough to commit to CVS! So maybe that's why nobody complained - Is it true that wrong results will be given in a lat/long location with no warning? If so, then something should be changed.
If not, and I've misunderstood, then it's all OK!

Paul

On Mon, Dec 11, 2006 at 07:05:01PM +0100, Jachym Cepicky wrote:

hi Markus,

On Mon, Dec 11, 2006 at 06:58:36PM +0100, Markus Neteler wrote:
> On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:
> > hi,
> >
> > since nobody really complained, I commited the patch. v.to.db has new
> > option "slope" now
>
> hi jachym,
>
> does it now work for LatLong? I guess I overlooked some email.
>
> Markus
>

yes, I was writing about this:

no, it does not :frowning: it does not even work with option=length, because of

Vect_cidx_get_num_unique_cats_by_index ( &Map,
Vect_cidx_get_field_index(&Map, options.field ) );

in main.c returns 1634887471 of unique cats by index and v.to.db ends up
with G_calloc error: could not allocat memory.

I have no clue, how to fix this bug.

Hi Jachym,

I don't think that we should knowingly introduce bugs in
GRASS. It would be good to get that resolved soon.
As Paul said - I also assumed that you would consider the
patch as non-ready, so I didn't further comment.

Best,
Markus

On Mon, Dec 11, 2006 at 09:34:02PM +0100, Markus Neteler wrote:

On Mon, Dec 11, 2006 at 07:05:01PM +0100, Jachym Cepicky wrote:
> On Mon, Dec 11, 2006 at 06:58:36PM +0100, Markus Neteler wrote:
> > On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:
> > > since nobody really complained, I commited the patch. v.to.db has new
> > > option "slope" now
> >
> > does it now work for LatLong? I guess I overlooked some email.
> >
> yes, I was writing about this:
>
> no, it does not :frowning: it does not even work with option=length, because of

In fact it works with length:

GRASS 6.3.cvs (latlong):~ > v.to.db -p polbnda_italy_state op=length un=k col=dummy type=boundary
cat|length
-1|8630.5217187381
1|0
2 categories read from map
0 records selected from table
0 categories read from map exist in selection from table
0 categories read from map don't exist in selection from table
0 records updated/inserted
0 update/insert errors

We fixed that one year ago:

2005-11-30 16:26 markus
        * areas.c, description.html: Wolf Bergenheim: use geodetic length
        for perimeter in LatLong; prettified areas.c with indent

to verify exactly the coastline length for Italy which is given incorrectly in
the ASPRS Grid & datums paper on Italy.

Markus

>
>
> Vect_cidx_get_num_unique_cats_by_index ( &Map,
> Vect_cidx_get_field_index(&Map, options.field ) );
>
> in main.c returns 1634887471 of unique cats by index and v.to.db ends up
> with G_calloc error: could not allocat memory.
>
> I have no clue, how to fix this bug.

Hi Jachym,

I don't think that we should knowingly introduce bugs in
GRASS. It would be good to get that resolved soon.
As Paul said - I also assumed that you would consider the
patch as non-ready, so I didn't further comment.

Best,
Markus

>> does it now work for LatLong? I guess I overlooked some email.
>>
[...]
> no, it does not :frowning: it does not even work with option=length,
> because of
>
> Vect_cidx_get_num_unique_cats_by_index ( &Map,
> Vect_cidx_get_field_index(&Map, options.field ) );
>
> in main.c returns 1634887471 of unique cats by index and v.to.db
> ends up with G_calloc error: could not allocat memory.
>
> I have no clue, how to fix this bug.

Paul:

I (maybe others) interpreted this as you admitting that the patch was
not yet ready/good enough to commit to CVS! So maybe that's why
nobody complained - Is it true that wrong results will be given in a
lat/long location with no warning? If so, then something should be
changed. If not, and I've misunderstood, then it's all OK!

a simple

if ((G_projection() == PROJECTION_LL))
   G_fatal_error("slope option not supported for lat/lon locations");

could allow the patch to go in without introducing bugs.

Of course we should try and fix the bug instead of coding around it,
and now is the time to do that.

Hamish

Markus Neteler wrote:

to verify exactly the coastline length for Italy which is given
incorrectly in the ASPRS Grid & datums paper on Italy.

to be pedantic:

coastline length is a classic fractal problem with no real answer.

the best you can do is assume the dataset was digitized with the same
fractal depth throughout (and that's a bad assumption) and then compare
relative sections of the vector as a ratio.

"The empirical evidence suggests a rule which, if extrapolated, shows
that the measured length increases without limit as the measurement
scale decreases towards zero."

http://en.wikipedia.org/wiki/How_Long_Is_the_Coast_of_Britain%3F_Statistical_Self-Similarity_and_Fractional_Dimension

or did you get different answers from the same dataset, reprojected?

Hamish

On Tue, Dec 12, 2006 at 01:40:18PM +1300, Hamish wrote:

Markus Neteler wrote:
> to verify exactly the coastline length for Italy which is given
> incorrectly in the ASPRS Grid & datums paper on Italy.

to be pedantic:

coastline length is a classic fractal problem with no real answer.

...

or did you get different answers from the same dataset, reprojected?

I am aware of this fractal problem but that was not the point.

One year ago the module reported a few *degree* as length
for a boundary which was nonsense for the user. Now it calculated
the geodetic length of the vector pieces.

Markus

PS: http://grass.itc.it/pipermail/grass-dev/2005-November/020030.html
    http://grass.itc.it/pipermail/grass-dev/2005-November/020099.html
    http://grass.itc.it/pipermail/grass-dev/2005-November/020160.html
    (then we solved it offlist)

hallo,
On Mon, Dec 11, 2006 at 07:01:21PM +0000, Paul Kelly wrote:

Hello Jachym
Just a little comment below:

On Mon, 11 Dec 2006, Jachym Cepicky wrote:

>On Mon, Dec 11, 2006 at 06:58:36PM +0100, Markus Neteler wrote:
>>On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:
>>>hi,
>>>
>>>since nobody really complained, I commited the patch. v.to.db has new
>>>option "slope" now
>>
>>hi jachym,
>>
>>does it now work for LatLong? I guess I overlooked some email.
>>
[...]
>no, it does not :frowning: it does not even work with option=length, because of
>
>
>Vect_cidx_get_num_unique_cats_by_index ( &Map,
>Vect_cidx_get_field_index(&Map, options.field ) );
>
>in main.c returns 1634887471 of unique cats by index and v.to.db ends up
>with G_calloc error: could not allocat memory.
>
>I have no clue, how to fix this bug.

I (maybe others) interpreted this as you admitting that the patch was not
yet ready/good enough to commit to CVS! So maybe that's why nobody
complained - Is it true that wrong results will be given in a lat/long
location with no warning? If so, then something should be changed.
If not, and I've misunderstood, then it's all OK!

Paul

Slope is calculated with line lenght. Calculating line length on
lat/long location does not work either. This patch adds new funtionality
and (should) does not break old ones. I tryed this in GRASS 6.2 and
calculating line length on lat/long location does not work there too.

So, as I got mostly positive feedback and as I did not break any
funtionality, I commited the patch.

I also tryed to describe, why this does not work on lat/long locations.
Sorry, I was not able to find out, where exactly the problem is. I
guess, some variable is not initialized.

If I should not commit the patch, because of this all, I'm sorry and
will remove this patch from cvs.

I'll fill the bug tracker for the length issue.

Jachym

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

hi,

ee, sorry, I was confused. It seems to, that option=length does not work
for vectors WITHOUT database connection.

When I tryed this on new vector, with connected database table,
everything seem to work fine:

v.digit -n line
v.drape in=line out=line3d rast=dem
v.to.db -p col=nothing map=line3d option=length
cat|length
1|4645.31351829853

v.to.db -p col=nothing map=line3d option=slope
cat|slope
1|-0.0559703879998248

d.what.rast
14:43:43.389044E 49:50:30.741694N
dmt in jachym, actual (530.000000)

14:39:59.979022E 49:51:15.627726N
dmt in jachym, actual (269.000000)

echo "(269-530)/4645.313518"|bc -l
-.056185

So I would say, that calculating slope works

?

Jachym

On Mon, Dec 11, 2006 at 09:40:42PM +0100, Markus Neteler wrote:

On Mon, Dec 11, 2006 at 09:34:02PM +0100, Markus Neteler wrote:
> On Mon, Dec 11, 2006 at 07:05:01PM +0100, Jachym Cepicky wrote:
> > On Mon, Dec 11, 2006 at 06:58:36PM +0100, Markus Neteler wrote:
> > > On Mon, Dec 11, 2006 at 06:53:57PM +0100, Jachym Cepicky wrote:
> > > > since nobody really complained, I commited the patch. v.to.db has new
> > > > option "slope" now
> > >
> > > does it now work for LatLong? I guess I overlooked some email.
> > >
> > yes, I was writing about this:
> >
> > no, it does not :frowning: it does not even work with option=length, because of

In fact it works with length:

GRASS 6.3.cvs (latlong):~ > v.to.db -p polbnda_italy_state op=length un=k col=dummy type=boundary
cat|length
-1|8630.5217187381
1|0
2 categories read from map
0 records selected from table
0 categories read from map exist in selection from table
0 categories read from map don't exist in selection from table
0 records updated/inserted
0 update/insert errors

We fixed that one year ago:

2005-11-30 16:26 markus
        * areas.c, description.html: Wolf Bergenheim: use geodetic length
        for perimeter in LatLong; prettified areas.c with indent

to verify exactly the coastline length for Italy which is given incorrectly in
the ASPRS Grid & datums paper on Italy.

Markus

> >
> >
> > Vect_cidx_get_num_unique_cats_by_index ( &Map,
> > Vect_cidx_get_field_index(&Map, options.field ) );
> >
> > in main.c returns 1634887471 of unique cats by index and v.to.db ends up
> > with G_calloc error: could not allocat memory.
> >
> > I have no clue, how to fix this bug.
>
> Hi Jachym,
>
> I don't think that we should knowingly introduce bugs in
> GRASS. It would be good to get that resolved soon.
> As Paul said - I also assumed that you would consider the
> patch as non-ready, so I didn't further comment.
>
> Best,
> Markus

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514