[GRASS-user] using v.line.center

Hi list,

in order to use v.line.center properly I use v.category to adjust category assignment.

As a result I get:

GRASS 6.2.2 (admeurop):> v.category in=bound1 layer=2 out=boundary1 --o
WARNING: The vector ‘boundary1’ already exists and will be overwritten.
116 new centroids placed in output map
Building topology …
711 primitives registered
Building areas: 100%
119 areas built
28 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 631
Number of primitives: 711
Number of points : 0
Number of lines : 0
Number of boundaries: 592
Number of centroids : 119
Number of areas : 119
Number of isles : 28
Number of incorrect boundaries : 299

Then I use v.line.center to get the middle points of the boundaries (That’s right?). Then I get the following result:

GRASS 6.2.2 (admeurop):/scratch/manuel/GISDATA/scripts > v.line.center in=boundary1 out=points1 --o
0 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
WARNING: The vector ‘points1’ already exists and will be overwritten.
Building topology …
0 primitives registered
0 areas built
0 isles built
Attaching islands:
Attaching centroids: Topology was built.
Number of nodes : 0
Number of primitives: 0
Number of points : 0
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0

Done.

So, I get nothing

Any can me help? I don’t understand this result.

cheers

Manuel

Manuel Sangiao wrote:

in order to use *v.line.center* properly I use* v.category*
to adjust category assignment.

As a result I get:

GRASS 6.2.2 (admeurop):> v.category in=bound1 layer=2 out=boundary1 --o

....

Number of lines : 0
Number of boundaries: 592

....

Then I use *v.line.center* to get the middle points of the
boundaries (That's right?). Then I get the following result:

....

0 records updated/inserted

....

So, I get nothing

Any can me help? I don't understand this result.

use v.type to convert boundaries to lines first.

Hamish

Thanks Hamish for your help,

that was helpful. But now, when I use v.line.center, I get the following error:

WARNING: Cannot get point on line: cat=927 offset=89379.795093 (line lenght=2.219076)
P 927 927 89379.795093

I guess the reason for this error is the projection (mapset?) unit. The projection unit(s) in my mapset is degree(s). And the length units are meters.

So, how can i change the mapset units. Should I create another mapset with the properly units?

regards

Manuel

2008/6/5, Hamish <hamish_b@yahoo.com>:

Manuel Sangiao wrote:

in order to use v.line.center properly I use* v.category*
to adjust category assignment.

As a result I get:

GRASS 6.2.2 (admeurop):> v.category in=bound1 layer=2 out=boundary1 --o

Number of lines : 0
Number of boundaries: 592

Then I use v.line.center to get the middle points of the
boundaries (That’s right?). Then I get the following result:

0 records updated/inserted

So, I get nothing

Any can me help? I don’t understand this result.

use v.type to convert boundaries to lines first.

Hamish

Manuel Sangiao pisze:

WARNING: Cannot get point on line: cat=927 offset=89379.795093 (line lenght=2.219076) P 927 927 89379.795093

I guess the reason for this error is the projection (mapset?) unit.
The projection unit(s) in my mapset is degree(s). And the length
units are meters.

v.line.center as it is can't work in latlon Location. It uses v.to.db
for length calculation, which cannot measure in degrees, and then pipes
the result to v.segment, which assumes Location unit - if it's degree
the script won't work.

It would be cool if v.segment could accept offsets in various units.

I should fix v.line.center to check location units, and update the
manual. Someday.

So, how can i change the mapset units. Should I create another mapset
with the properly units?

Reproject the data into a metric location.

--
Maciej Sieczka
www.sieczka.org

Hi,

2008/6/5 Maciej Sieczka <tutey@o2.pl>:

It would be cool if v.segment could accept offsets in various units.

I have created for that trac ticket

http://trac.osgeo.org/grass/ticket/182

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

On Thu, Jun 5, 2008 at 7:38 PM, Maciej Sieczka <tutey@o2.pl> wrote:

Manuel Sangiao pisze:

WARNING: Cannot get point on line: cat=927 offset=89379.795093 (line
lenght=2.219076) P 927 927 89379.795093

I guess the reason for this error is the projection (mapset?) unit.
The projection unit(s) in my mapset is degree(s). And the length
units are meters.

v.line.center as it is can't work in latlon Location. It uses v.to.db
for length calculation, which cannot measure in degrees,

I think it can... from the man page:
"When calculating perimeters in Latitude-Longitude locations, the geodesic
distance between the vertices is used.
"

Maybe the problem is different? remember to add "-x" to the first
line of v.line.center to obtain detailed steps of processing (shell
debugging).

Markus

Markus Neteler pisze:

On Thu, Jun 5, 2008 at 7:38 PM, Maciej Sieczka <tutey@o2.pl> wrote:

Manuel Sangiao pisze:

WARNING: Cannot get point on line: cat=927 offset=89379.795093 (line
lenght=2.219076) P 927 927 89379.795093

I guess the reason for this error is the projection (mapset?) unit.
The projection unit(s) in my mapset is degree(s). And the length
units are meters.

v.line.center as it is can't work in latlon Location. It uses v.to.db
for length calculation, which cannot measure in degrees,

I think it can... from the man page:
"When calculating perimeters in Latitude-Longitude locations, the geodesic
distance between the vertices is used.
"

Markus

v.line.center uses v.to.db to calculate lengths of input vector lines, which then are fed into v.segment as offsets to create lines' center points.

v.segment expects offsets in units of the Location. If these are degrees we have a problem because v.to.db can't calculate length in degrees. It supports the following units:

mi,miles,f,feet,me,meters,k,kilometers,a,acres,h,hectares

Therefore, v.line center can't work in latlon locations.

--
Maciej Sieczka
www.sieczka.org

Hi all,

after the reprojection in another mapset I used v.line.center, all ok. But, I obtain a new layer without database. The input layer have database.

v.db.connect -p glines1
Vector map is connected by:
layer <2> table in database </scratch/manuel/GISDATA//admprojected/manuel/dbf/> through driver with key

That is the result of all:

GRASS 6.2.2 (admprojected):~ > v.line.center in=glines1@manuel layer=2 out=pts1 --o
587 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
WARNING: The vector ‘pts1’ already exists and will be overwritten.
WARNING: Cannot get point on line: cat = -1 offset = 171.957102 (line
length = 23.086715)
P -1 -1 171.9571019845255080
Building topology …
586 primitives registered
Building areas: 100%
0 areas built
0 isles built
Attaching islands:
Attaching centroids: 100%
Topology was built.
Number of nodes : 586
Number of primitives: 586
Number of points : 586
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0

Done.

GRASS 6.2.2 (admprojected):~ > v.db.connect -p pts1
ERROR: Database connection for map is not defined in DB file

I have read that the result layer (pts1) contains the category numbers of the input vector line layer.

Is there a solution?

Cheers

Manuel

Manuel Sangiao pisze:

Hi all,

after the reprojection in another mapset I used v.line.center, all
ok. But, I obtain a new layer without database. The input layer have
database.

v.line.center does not copy the input vector's table to output vector.

v.db.connect -p glines1 Vector map <glines1> is connected by: layer
<2> table <glines1> in database </scratch/manuel/GISDATA//admprojected/manuel/dbf/> through driver
<dbf> with key <cat>

I have read that the result layer (pts1) contains the category
numbers of the input vector line layer.

Is there a solution?

Yes. As the category numbers are the same, you can:

# given that the name of the v.line.center's input vector is "lines" and
# the output is "points":

# copy the input table:
db.copy from_table=lines to_table=points

# connect the table "points" to vector map "points":
v.db.connect points table=points

Now query (d.what.vect, v.db.select) to check if everything's OK.

Mind that I assume plenty of defaults in the example above - verify your
layer number, key column name etc. Refer to to commands's manuals.

Maciek

--
Maciej Sieczka
www.sieczka.org

Dzie,kuje bardzo Maciej,

It has worked,

2008/6/6 Maciej Sieczka tutey@o2.pl:

Manuel Sangiao pisze:

Hi all,

after the reprojection in another mapset I used v.line.center, all
ok. But, I obtain a new layer without database. The input layer have
database.

v.line.center does not copy the input vector’s table to output vector.

v.db.connect -p glines1 Vector map is connected by: layer
<2> table in database </scratch/manuel/GISDATA//admprojected/manuel/dbf/> through driver
with key

I have read that the result layer (pts1) contains the category
numbers of the input vector line layer.

Is there a solution?

Yes. As the category numbers are the same, you can:

given that the name of the v.line.center’s input vector is “lines” and

the output is “points”:

copy the input table:

db.copy from_table=lines to_table=points

connect the table “points” to vector map “points”:

v.db.connect points table=points

Now query (d.what.vect, v.db.select) to check if everything’s OK.

Mind that I assume plenty of defaults in the example above - verify your
layer number, key column name etc. Refer to to commands’s manuals.

Maciek


Maciej Sieczka
www.sieczka.org