Micha,
attached a txt-file with the output you asked for. Following workaround
did work for the files, which makes me think that it is not a problem of
postgresql:
v.db.addcolumn map=GR_xy_wohnort col="x_arbeit double precision,
y_arbeit double precision"
echo "UPDATE GR_xy_wohnort SET x_arbeit=(SELECT x_arbeit FROM
GR_xy_arbeitsort WHERE GR_xy_arbeitsort.id=GR_xy_wohnort.id)" > help1.txt
echo "UPDATE GR_xy_wohnort SET y_arbeit=(SELECT y_arbeit FROM
GR_xy_arbeitsort WHERE GR_xy_arbeitsort.id=GR_xy_wohnort.id)" > help2.txt
db.execute help1.txt
db.execute help2.txt
rm help2.txt
rm help1.txt
Cheers, Patrick
On 12/03/2010 03:47 PM, Micha Silver wrote:
On 03/12/2010 16:01, Micha Silver wrote:
On 12/03/2010 09:53 AM, Patrick_schirmer wrote:
Thanks Micha,
Yes, commands are what I typed, just renamed the filenames before
sending mail to the list:
x_arbeit = x_last
x_wohn = x_current
/That syntax is an error in postgres: double precision does not take
a length qualifier.
There's nothing in the v.db.join script that I can find that would
add such a thing./"
Is it a problem of postgres or of v.db.addcolumn which is called
within v.db.join? Can someone reproduce this mistake?
Well, postgresql doesn't accept a length qualifier for the type
"double precision". But the grass module v.db.addcol doesn't add any
qualifier either. So I can't see where the error is originating from.
Would you mind to post the output of:
v.info -c
v.db.connect -p
for each of the point vectors?
Maybe that will give us some hint...
And one more test, please:
db.describe table=<your vector points map>
Cheers, Patrick
On 12/01/2010 08:48 PM, Micha Silver wrote:
Hi Patrick
On 12/01/2010 05:29 PM, Patrick_schirmer wrote:
Hi, me again :-/
I got two vectorfiles with points - one file representing the
current location of persons and the other one representing
previous locations of the same persons. Persons are unique and
have an id which is present in both files. I would like to
calculate the distance each person has moved. Thought it would be
best doing this in the datbase.
_my approach:_
v.db.addcolumn map=GR_xy_current col="x_current double precision,
y_current double precision, distance double precision"
v.db.addcolumn map=GR_xy_last col="x_last double precision, y_last
double precision"
v.to.db map=GR_xy_current option=coor col=x_current,y_current
v.to.db map=GR_xy_last option=coor col=x_last,y_last
v.db.join map=GR_xy_current column=id otable=GR_xy_last ocolumn=id
_All commands will run except the last one, creating this error:_
DBMI-Postgres driver error:
Cannot execute:
ALTER TABLE GR_xy_current ADD COLUMN x_arbeit DOUBLE PRECISION(8)
ERROR: syntax error at or near "("
LINE 1: ... TABLE GR_xy_current ADD COLUMN x_arbeit DOUBLE
PRECISION(8)
^
ERROR: Error while executing: 'ALTER TABLE GR_xy_current ADD COLUMN
x_last DOUBLE PRECISION(8)'
ERROR: Unable to add column <x_last DOUBLE PRECISION(8)>.
ERROR: Error creating column <x_last>.
datbase: PG; Grass-version 7.0
GRASS 7.0.svn (Survey):~ > v.info -c GR_xy_wohnort
Displaying column types/names for database connection of layer <1>:
INTEGER|cat
INTEGER|plz
CHARACTER|ort
CHARACTER|strasse
CHARACTER|nr
INTEGER|id
CHARACTER|lat
CHARACTER|lon
DOUBLE PRECISION|x_wohn
DOUBLE PRECISION|y_wohn
DOUBLE PRECISION|dist_arbei
DOUBLE PRECISION|dist_lwohn
DOUBLE PRECISION|x_arbeit
DOUBLE PRECISION|y_arbeit
DOUBLE PRECISION|x_lastwohn
DOUBLE PRECISION|y_lastwohn
CHARACTER|nan
GRASS 7.0.svn (Survey):~ > v.info -c GR_xy_arbeitsort
Displaying column types/names for database connection of layer <1>:
INTEGER|cat
INTEGER|plz
CHARACTER|ort
CHARACTER|strasse
CHARACTER|nr
INTEGER|id
CHARACTER|lat
CHARACTER|lon
DOUBLE PRECISION|x_arbeit
DOUBLE PRECISION|y_arbeit
GRASS 7.0.svn (Survey):~ >
GRASS 7.0.svn (Survey):~ > v.db.connect -p GR_xy_wohnort
Vector map <GR_xy_wohnort> is connected by:
layer <1/xy_wohnort> table <GR_xy_wohnort> in database <schirpat> through
driver <pg> with key <cat>
GRASS 7.0.svn (Survey):~ >GRASS 7.0.svn (Survey):~ > v.db.connect -p
GR_xy_arbeitsort
Vector map <GR_xy_arbeitsort> is connected by:
layer <1/xy_arbeitsort> table <GR_xy_arbeitsort> in database <schirpat> through
driver <pg> with key <cat>
GRASS 7.0.svn (Survey):~ >
GRASS 7.0.svn (Survey):~ > db.describe table=GR_xy_wohnort
table:GR_xy_wohnort
description:
insert:?
delete:?
ncols:17
nrows:502
column:cat
description:
type:INTEGER
len:4
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:plz
description:
type:INTEGER
len:4
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:ort
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:strasse
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:nr
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:id
description:
type:INTEGER
len:4
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:lat
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:lon
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:x_wohn
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:y_wohn
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:dist_arbei
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:dist_lwohn
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:x_arbeit
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:y_arbeit
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:x_lastwohn
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:y_lastwohn
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:nan
description:
type:CHARACTER
len:3
scale:0
precision:0
default:
nullok:yes
select:?
update:?
GRASS 7.0.svn (Survey):~ >
GRASS 7.0.svn (Survey):~ > db.describe table=GR_xy_arbeitsort
table:GR_xy_arbeitsort
description:
insert:?
delete:?
ncols:10
nrows:330
column:cat
description:
type:INTEGER
len:4
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:plz
description:
type:INTEGER
len:4
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:ort
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:strasse
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:nr
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:id
description:
type:INTEGER
len:4
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:lat
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:lon
description:
type:CHARACTER
len:80
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:x_arbeit
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
column:y_arbeit
description:
type:DOUBLE PRECISION
len:8
scale:0
precision:0
default:
nullok:yes
select:?
update:?
GRASS 7.0.svn (Survey):~ >
Having a look at the table via PGAdmin III will show:
CREATE TABLE gr_xy_wohnort
(
cat integer,
plz integer,
ort character varying(80),
strasse character varying(80),
nr character varying(80),
id integer,
lat character varying(80),
lon character varying(80),
x_wohn double precision,
y_wohn double precision,
dist_arbei double precision,
dist_lwohn double precision,
x_arbeit double precision,
y_arbeit double precision,
x_lastwohn double precision,
y_lastwohn double precision,
nan character varying(3)
)
Example of value x_arbeit: 683950.999985278
Example of value y_arbeit: 245281.003081325
Exampe of value x_wohnort: 696969.00272016
Example of value y_wohnort: 241017.00360929
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user