[GRASS5] vector point extract script

Hi,

not knowing enough SQL magic to do this properly*, I've written a little
script to extract point data from vector points files, including x,y(,z)
and any selected columns from the db of the same name.

Assumes db and vector file both have the same category number/order.
This may well be a bad assumption!

v.out.ascii.db:
  http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns

[*] I guess make 2 new columns containing x,y values then db.select. How?

Hamish

Hamish wrote:

Hi,

not knowing enough SQL magic to do this properly*, I've written a little
script to extract point data from vector points files, including x,y(,z)
and any selected columns from the db of the same name.

Assumes db and vector file both have the same category number/order.
This may well be a bad assumption!

v.out.ascii.db: http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns

[*] I guess make 2 new columns containing x,y values then db.select. How?

Hamish

paste is probably dangerous, a record aor point can be missing. Isn't it better to use join (input must be sorted; use -e for attributes)?

The possibility to export attributes should be added to v.out.ascii, but it must be done better than in v.out.ogr. All attributes must be selected by one query and read points using category index and keep an array of flags if the point was printed. At the end output points without attributes.

Radim

Hamish:

> not knowing enough SQL magic to do this properly*, I've written a
> little script to extract point data from vector points files,
> including x,y(,z) and any selected columns from the db of the same
> name.
>
> Assumes db and vector file both have the same category number/order.
> This may well be a bad assumption!
>
> v.out.ascii.db:
> http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns
>
>
> [*] I guess make 2 new columns containing x,y values then db.select.
> How?

Radim:

paste is probably dangerous, a record aor point can be missing. Isn't
it better to use join (input must be sorted;

Yes it is; thanks. Script updated to use sort+join.

use -e for attributes)?

Use -e where? for what?

The possibility to export attributes should be added to v.out.ascii,
but it must be done better than in v.out.ogr. All attributes must be
selected by one query and read points using category index and keep an
array of flags if the point was printed. At the end output points
without attributes.

added to the wish list. No time to try (ie learn) today.

Hamish

Hamish wrote:

Hamish:

not knowing enough SQL magic to do this properly*, I've written a
little script to extract point data from vector points files,
including x,y(,z) and any selected columns from the db of the same
name.

Assumes db and vector file both have the same category number/order.
This may well be a bad assumption!

v.out.ascii.db: http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns

[*] I guess make 2 new columns containing x,y values then db.select.
How?

Radim:

paste is probably dangerous, a record aor point can be missing. Isn't
it better to use join (input must be sorted;

Yes it is; thanks. Script updated to use sort+join.

use -e for attributes)?

Use -e where? for what?

To print lines with missing attributes in join.

Radim

>>paste is probably dangerous, a record aor point can be missing.
>Isn't >it better to use join (input must be sorted;
>
> Yes it is; thanks. Script updated to use sort+join.

..

>>use -e for attributes)?
>
> Use -e where? for what?

To print lines with missing attributes in join.

You mean if you have 1000 vector points but only 800 records in the
db table? I don't have any data to test that.

Hopefully -e defaults to "" then?

?
Hamish

Hamish wrote:

paste is probably dangerous, a record aor point can be missing.

Isn't >it better to use join (input must be sorted;

Yes it is; thanks. Script updated to use sort+join.

..

use -e for attributes)?

Use -e where? for what?

To print lines with missing attributes in join.

You mean if you have 1000 vector points but only 800 records in the
db table? I don't have any data to test that.

Or 999 or 0.

Hopefully -e defaults to "" then?

IIRC, if -e is not used, the leftside is not printed.
'join' is dumb.

Radim