[GRASS-user] importing a vector, problem with duplicate column name: cat_

Hi,

importing a vector either using v.import GUI or v.in.ogr, it tries to rename the column into <cat_>, but both already exist and it throws out an error.

[…]
Check if OGR layer <pt599000_4414000_class1> contains polygons…
Column name renamed to <cat_>
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: cat_
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: cat_
ERROR: Unable to create table: ‘create table pt599000_4414000_class1 (cat integer, cat_ integer, cat_ integer, NDVI double precision)’
ERROR: Unable to import […]

Is there a way to overcome this?

Thank you for any suggestion

Cheers,

···

Margherita Di Leo

On Thu, Aug 4, 2016 at 9:24 AM, Margherita Di Leo <diregola@gmail.com> wrote:

Hi,

importing a vector either using v.import GUI or v.in.ogr, it tries to rename
the column <cat> into <cat_>, but both already exist and it throws out an
error.

[..]
Check if OGR layer <pt599000_4414000_class1> contains polygons...
Column name <cat> renamed to <cat_>
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: cat_
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: cat_
ERROR: Unable to create table: 'create table pt599000_4414000_class1 (cat
integer, cat_ integer, cat_ integer, NDVI double precision)'
ERROR: Unable to import [..]

Is there a way to overcome this?

you can overcome this with the columns option of v.in.ogr.

Markus M

Thank you for any suggestion
Cheers,

--
Margherita Di Leo

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Markus,

···

On Thu, Aug 4, 2016 at 9:48 AM, Markus Metz <markus.metz.giswork@gmail.com> wrote:

On Thu, Aug 4, 2016 at 9:24 AM, Margherita Di Leo <diregola@gmail.com> wrote:

Hi,

importing a vector either using v.import GUI or v.in.ogr, it tries to rename
the column into <cat_>, but both already exist and it throws out an
error.

[…]

Is there a way to overcome this?

you can overcome this with the columns option of v.in.ogr.

Thank you for your suggestion. Do I understand correctly that this will add a third column? If in my work flow I have to import-process-export multiple times, this will add a column every time unless I explicitly drop a column?

Margherita Di Leo

On Thu, Aug 4, 2016 at 10:06 AM, Margherita Di Leo <diregola@gmail.com> wrote:

Markus,

On Thu, Aug 4, 2016 at 9:48 AM, Markus Metz <markus.metz.giswork@gmail.com>
wrote:

On Thu, Aug 4, 2016 at 9:24 AM, Margherita Di Leo <diregola@gmail.com>
wrote:
> Hi,
>
> importing a vector either using v.import GUI or v.in.ogr, it tries to
> rename
> the column <cat> into <cat_>, but both already exist and it throws out
> an
> error.
>

[...]

>
> Is there a way to overcome this?

you can overcome this with the columns option of v.in.ogr.

Thank you for your suggestion. Do I understand correctly that this will add
a third column?

The columns option does not add another column, it provides column
names: "List of column names to be used instead of original names,
first is used for category column"

If in my work flow I have to import-process-export multiple
times, this will add a column every time unless I explicitly drop a column?

Yes, or use the key option of v.in.ogr. With your vector you could use
v.in.ogr key=cat, then drop the cat_ column. The next time you
re-import the vector, use again the key option, this should avoid that
"categories are generated as unique values and stored in [in a newly
created] 'cat' column"

Markus M

--
Margherita Di Leo

On Thu, Aug 4, 2016 at 10:29 AM, Markus Metz <markus.metz.giswork@gmail.com>
wrote:

On Thu, Aug 4, 2016 at 10:06 AM, Margherita Di Leo <diregola@gmail.com>
wrote:

> If in my work flow I have to import-process-export multiple
> times, this will add a column every time unless I explicitly drop a
column?

Yes, or use the key option of v.in.ogr. With your vector you could use
v.in.ogr key=cat, then drop the cat_ column. The next time you
re-import the vector, use again the key option, this should avoid that
"categories are generated as unique values and stored in [in a newly
created] 'cat' column"

Genau. Thank you

Cheers,

--
Margherita Di Leo

On Thu, Aug 4, 2016 at 10:06 AM, Margherita Di Leo <diregola@gmail.com> wrote:
...

Thank you for your suggestion. Do I understand correctly that this will add
a third column? If in my work flow I have to import-process-export multiple
times, this will add a column every time unless I explicitly drop a column?

... or just don't export it if you don't need the cat column:

https://grass.osgeo.org/grass72/manuals/v.out.ogr.html
-s Skip export of GRASS category ID ('cat') attribute

best
markusN