[GRASS5] [bug #3623] (grass) v.in.ogr fails when input contains a column 'CAT'

this bug's URL: http://intevation.de/rt/webrt?serial_num=3623
-------------------------------------------------------------------------

Subject: v.in.ogr fails when input contains a column 'CAT'

Platform: GNU/Linux/i386
grass obtained from: CVS
grass binary for platform: Compiled from Sources
GRASS Version: cvs 23.08.05

details:

GRASS 6.1.cvs (caves_utm33):~ > v.in.ogr dsn=/home/trawiarz/poz_fault_patch_cut_pt_extr/poz_fault_patch_cut_pt_extr.shp output=poz_fault_patch_cut_pt_extr_re layer=poz_fault_patch_cut_pt_extr min_area=0.0001 snap=-1
A datum name wgs84 (WGS_1984) was specified without transformation parameters.
Note that the GRASS default for wgs84 is towgs84=0.000,0.000,0.000.
Projection of input dataset and current location appear to match.
Proceeding with import...
Layer: poz_fault_patch_cut_pt_extr
DBMI-DBF driver error:
Column 'CAT' already exists (duplicate name)
Cannot create table.
Error in db_execute_immediate()

GRASS_INFO_ERROR(9053,1): Cannot create table: create table poz_fault_patch_cut_pt_extr_re (cat integer, CAT double precision, WYS double precision, SM double precision, WYS_MULT double precision)

Here's the problematic file:
http://www.biol.uni.wroc.pl/sieczka/udostepnione/vinogr/poz_fault_patch_cut_pt_extr.tar.bz2

It was created in Grass, edited in OO.org and exported with v.out.ogr.

Maciek

-------------------------------------------- Managed by Request Tracker

this bug's URL: http://intevation.de/rt/webrt?serial_num=3623
---------------------------------------------------------------------

Subject: v.in.ogr fails when input contains a column 'CAT'

GRASS Version: cvs 23.08.05

details:

GRASS 6.1.cvs (caves_utm33):~ > v.in.ogr
dsn=/home/trawiarz/poz_fault_patch_cut_pt_extr/poz_fault_patch_cut_pt
_extr.shp output=poz_fault_patch_cut_pt_extr_re
layer=poz_fault_patch_cut_pt_extr min_area=0.0001 snap=-1
A datum name wgs84 (WGS_1984) was specified without transformation
parameters.
Note that the GRASS default for wgs84 is towgs84=0.000,0.000,0.000.
Projection of input dataset and current location appear to match.
Proceeding with import... Layer: poz_fault_patch_cut_pt_extr
DBMI-DBF driver error:
Column 'CAT' already exists (duplicate name)
Cannot create table.
Error in db_execute_immediate()

GRASS_INFO_ERROR(9053,1): Cannot create table: create table
poz_fault_patch_cut_pt_extr_re (cat integer, CAT double precision, WYS
double precision, SM double precision, WYS_MULT double precision)

use the cnames= option to rename the column to something non-reserved,
or make CAT column of type integer if it is in fact a category column?

v.in.ogr:
    cnames List of column names to be used instead of original names,
first is used for category column

or v.in.db depending on format of file.

Hamish

From: "Hamish" <hamish_nospam@yahoo.com>

use the cnames= option to rename the column to something non-reserved,

You are right in general.

But there is something more to it. If my input shapefile contains 'cat'
column (*lowercase*), it is imported without the error message as 'cat_'.
The error pops up only when the column name is 'CAT' - uppercase.

Neither behaviour is a good solution I think. Forcing 'cat_' is no good
because it may always happen that you want to export your vector file again
to shapefile for external processing and the import it back to Grass. Then
you end up with a message:

DBMI-DBF driver error:
Column 'cat_' already exists (duplicate name)
Cannot create table.
Error in db_execute_immediate()

No good.

My idea is that any time 'CAT' or 'cat' is present in the input, a warning
and instruction should be issued like:

"A column named 'CAT' or 'cat' is present in your input data. This column is
RESERVED for Grass to store "categories". Read more here: (a link to where
the user he can read more about what "categories" in Grass are; but is there
such a place?). Please rename your 'CAT' or 'cat' using the cnames option in
v.in.ogr to override conflicting column name."

What do you think?

The other, automated, solution could be to rename 'cat' to, say, 'cat1'. And
if 'cat1' is present to 'cat2' etc. Same with 'CAT'. Any good?

Maciek

P.S.
I mean this solutions mainly to help Grass newbies. I imagine that could be quite a surprise for a newbie to read "Column 'CAT' already exists (duplicate name)" with no guiding why so and what to do with it to able to import his shapefile anyway. But maybe I'm just exagerating here. You decide. I'll complain ;).

AND if the existing table contains a column named cat_, it will OGR will
fail.

In other words, if you append 2 tables together using OGR, it will rename
the old column cat_ and provide a new column--with a single integer
series--called CAT. If you try and append THAT table to another one, it will
fail because it tries to make a duplicate cat_ column.

Ideally, it should just continue to append existing cat numbers to existing
cat_ column, and continue with the existing series in CAT.

Michael
______________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Maciek Sieczka <werchowyna@epf.pl>
Date: Wed, 14 Sep 2005 19:37:50 +0200
To: Hamish <hamish_nospam@yahoo.com>, Request Tracker
<grass-bugs@intevation.de>
Cc: grass devel <grass5@grass.itc.it>
Subject: Re: [GRASS5] [bug #3623] (grass) v.in.ogr fails when input contains a
column 'CAT'

From: "Hamish" <hamish_nospam@yahoo.com>

use the cnames= option to rename the column to something non-reserved,

You are right in general.

But there is something more to it. If my input shapefile contains 'cat'
column (*lowercase*), it is imported without the error message as 'cat_'.
The error pops up only when the column name is 'CAT' - uppercase.

Neither behaviour is a good solution I think. Forcing 'cat_' is no good
because it may always happen that you want to export your vector file again
to shapefile for external processing and the import it back to Grass. Then
you end up with a message:

DBMI-DBF driver error:
Column 'cat_' already exists (duplicate name)
Cannot create table.
Error in db_execute_immediate()

No good.

My idea is that any time 'CAT' or 'cat' is present in the input, a warning
and instruction should be issued like:

"A column named 'CAT' or 'cat' is present in your input data. This column is
RESERVED for Grass to store "categories". Read more here: (a link to where
the user he can read more about what "categories" in Grass are; but is there
such a place?). Please rename your 'CAT' or 'cat' using the cnames option in
v.in.ogr to override conflicting column name."

What do you think?

The other, automated, solution could be to rename 'cat' to, say, 'cat1'. And
if 'cat1' is present to 'cat2' etc. Same with 'CAT'. Any good?

Maciek

P.S.
I mean this solutions mainly to help Grass newbies. I imagine that could be
quite a surprise for a newbie to read "Column 'CAT' already exists
(duplicate name)" with no guiding why so and what to do with it to able to
import his shapefile anyway. But maybe I'm just exagerating here. You
decide. I'll complain ;).