[GRASS-dev] v.dissolve not working with string column

Michael Barton Michael.Barton at asu.edu
Wed Apr 4 10:58:30 EDT 2012


Thanks very much. For sqlite, there is no field type called "character". I tried changing the field type to varchar, but that didn't work either.

Michael

On Apr 4, 2012, at 1:49 AM, Markus Metz wrote:

> On Wed, Apr 4, 2012 at 8:11 AM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
>> On 04/04/12 07:56, Michael Barton wrote:
>>> 
>>> I'm trying to do a dissolve but keep getting an error saying that it
>>> only works with integer or string columns. But the column I'm using for
>>> the dissolve IS string.
>>> 
>>> GRASS 7.0.svn (Spain_utm_wgs84z30):~ > db.describe table=muro_temp
>>> table:muro_temp
>>> description:
>>> insert:?
>>> delete:?
>>> ncols:4
>>> nrows:177
>>> 
>>> column:cat
>>> description:
>>> type:INTEGER
>>> len:20
>>> scale:0
>>> precision:0
>>> default:
>>> nullok:yes
>>> select:?
>>> update:?
>>> 
>>> column:Subsector
>>> description:
>>> type:TEXT
>>> len:1000
>>> scale:0
>>> precision:0
>>> default:
>>> nullok:yes
>>> select:?
>>> update:?
>>> 
>>> column:valley
>>> description:
>>> type:TEXT
>>> len:1000
>>> scale:0
>>> precision:0
>>> default:
>>> nullok:yes
>>> select:?
>>> update:?
>>> 
>>> column:sector
>>> description:
>>> type:TEXT
>>> len:1000
>>> scale:0
>>> precision:0
>>> default:
>>> nullok:yes
>>> select:?
>>> update:?
>>> 
>>> 
>>> GRASS 7.0.svn (Spain_utm_wgs84z30):~ > v.dissolve input=muro_temp
>>> column=sector output=muro_sectors3
>>> ERROR: Key column must be of type integer or string
>>> GRASS 7.0.svn (Spain_utm_wgs84z30):~ >
>>> 
>>> 
>>> Note above that the column "sector" IS text.
>>> 
>>> So what is wrong?
>> 
>> 
>> v.dissolve checks for integer and character, but not for text.
>> 
>> Try this simple patch:
>> 
>> --- v.dissolve.py       2011-08-17 13:49:29.000000000 +0200
>> +++ v.dissolve.new.py   2012-04-04 08:04:00.000000000 +0200
>> @@ -66,7 +66,7 @@
>>         except KeyError:
>>             grass.fatal(_('Column <%s> not found') % column)
>> 
>> -       if coltype['type'] not in ('INTEGER', 'CHARACTER'):
>> +       if coltype['type'] not in ('INTEGER', 'CHARACTER', 'TEXT'):
>>            grass.fatal(_("Key column must be of type integer or string"))
>> 
>>         f = grass.vector_layer_db(input, layer)
>> 
> 
> I have committed the patch and also added SMALLINT as valid integer in r51246.
> 
> Markus M

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity 
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu







More information about the grass-dev mailing list