[GRASS-user] problem with v.db.update and categories

Hello, I'm trying to polygonize a lines layers. I imported the layer in
grass with v.in.ogr as boundaries, then I attached the centroids with
v.centroid.
Probably because of the polygonize, some attribute are lost in in the
output map, so I have to update the table to fix the attributes:
v.db.update input='polygons' col=building, value='3.0'

After the update, the table look fine with v.db.select: all record have
the right value. But if I export the layer with ogr, some records do not
have attributes at all. My export command looks so.
v.out.ogr format='PostgreSQL' input='polygons' type='area'
dsn='PG:dbname=test_project host=localhost' olayer='test_table'
This warning is raise by v.to.ogr: WARNING: 8 features without attributes were written

I guess, the map categories are not synchronized with the database.
v.categories returns 1018 results, while the map contains only 298 records:
v.category polygons option=print | wc
      1018 1018 5133

Where are so many categories coming from? How can I synchronize map and
database?
Thanks, Tomm

Ok, now can I add the missing categories in dbf table with:
v.to.db map='polygons' type='centroid' option='cat'
But the update command is still failing:
v.db.update map=polygons col=building value=3.0

The new categories in dbf table have still empty 'building' attributes...

On Wed, 03 Dec 2014 09:42:28 +0100, tommaso <tommasodb@googlemail.com> wrote:

Hello, I'm trying to polygonize a lines layers. I imported the layer in
grass with v.in.ogr as boundaries, then I attached the centroids with
v.centroid.
Probably because of the polygonize, some attribute are lost in in the
output map, so I have to update the table to fix the attributes:
v.db.update input='polygons' col=building, value='3.0'

After the update, the table look fine with v.db.select: all record have
the right value. But if I export the layer with ogr, some records do not
have attributes at all. My export command looks so.
v.out.ogr format='PostgreSQL' input='polygons' type='area'
dsn='PG:dbname=test_project host=localhost' olayer='test_table'
This warning is raise by v.to.ogr: WARNING: 8 features without attributes were written

I guess, the map categories are not synchronized with the database.
v.categories returns 1018 results, while the map contains only 298 records:
v.category polygons option=print | wc
      1018 1018 5133

Where are so many categories coming from? How can I synchronize map and
database?
Thanks, Tomm

It seems to work better with the sqlite driver...
Maybe the command v.db.update does not work with DBF driver?

Thanks, Tommaso

On Wed, 03 Dec 2014 12:18:13 +0100, tommaso <tommasodb@googlemail.com> wrote:

Ok, now can I add the missing categories in dbf table with:
v.to.db map='polygons' type='centroid' option='cat'
But the update command is still failing:
v.db.update map=polygons col=building value=3.0

The new categories in dbf table have still empty 'building' attributes...

On Wed, 03 Dec 2014 09:42:28 +0100, tommaso <tommasodb@googlemail.com> wrote:

Hello, I'm trying to polygonize a lines layers. I imported the layer in
grass with v.in.ogr as boundaries, then I attached the centroids with
v.centroid.
Probably because of the polygonize, some attribute are lost in in the
output map, so I have to update the table to fix the attributes:
v.db.update input='polygons' col=building, value='3.0'

After the update, the table look fine with v.db.select: all record have
the right value. But if I export the layer with ogr, some records do not
have attributes at all. My export command looks so.
v.out.ogr format='PostgreSQL' input='polygons' type='area'
dsn='PG:dbname=test_project host=localhost' olayer='test_table'
This warning is raise by v.to.ogr: WARNING: 8 features without attributes were written

I guess, the map categories are not synchronized with the database.
v.categories returns 1018 results, while the map contains only 298 records:
v.category polygons option=print | wc
      1018 1018 5133

Where are so many categories coming from? How can I synchronize map and
database?
Thanks, Tomm

On Mon, Dec 8, 2014 at 10:37 AM, tommaso <tommasodb@googlemail.com> wrote:

It seems to work better with the sqlite driver...
Maybe the command v.db.update does not work with DBF driver?

The DBF driver is not ideal at all for SQL related jobs. Maybe GRASS
GIS is the only software which offers a bit of SQL for DBF :slight_smile:
But for real work use SQLite or a DB backend. This is the reason why
we chose SQLite as default backend in GRASS GIS 7.

Markus