[GRASS-user] v.dissolve bugfeature / workaround needed

Hello list,

i am using GRASS 6.4svn to merge adjacent poylgons into larger units. The merging is controlled by a column of type CHAR:

v.dissolve input=counties output=counties_merged_fips1 column=FIPS_1

results in
dbmi: Protocol error
ERROR: Cannot open select cursor: SELECT cat, FIPS_1 FROM counties
       ORDER BY FIPS_1
ERROR: Unable to open vector map <counties_fips1_22157@admin_borders>
       on topology level 2
WARNING: Table <counties_fips1_22157> linked to vector map
         <counties_fips1_22157> does not exist
ERROR: Vector map <counties_fips1> not found in the current mapset

v.dissolve works correctly when applied to an INT column.

I assume this is a bugfeature - string-based dissolving would be great to have at some point.

For now, does anybody have a (DBdriver-)SQL-hack to transmogrify strings like "GRASS001", "GRASS002", "GRASS003" into the Integers 1,2,3 ? (aka getting rid of the "GRASS"-part of the string) ?

Cheers,
Peter
--
Dr. Peter Löwe
<peter.loewe@gmx.de>

GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

On 06/08/08 15:09, peter.loewe@gmx.de wrote:

Hello list,

i am using GRASS 6.4svn to merge adjacent poylgons into larger units.
The merging is controlled by a column of type CHAR:

v.dissolve input=counties output=counties_merged_fips1 column=FIPS_1

results in dbmi: Protocol error ERROR: Cannot open select cursor:
SELECT cat, FIPS_1 FROM counties ORDER BY FIPS_1 ERROR: Unable to
open vector map <counties_fips1_22157@admin_borders> on topology
level 2 WARNING: Table <counties_fips1_22157> linked to vector map <counties_fips1_22157> does not exist ERROR: Vector map
<counties_fips1> not found in the current mapset

v.dissolve works correctly when applied to an INT column.

I assume this is a bugfeature -

v.dissolve is only a frontend script to v.reclass which needs ints...

string-based dissolving would be
great to have at some point.

+1

For now, does anybody have a (DBdriver-)SQL-hack to transmogrify
strings like "GRASS001", "GRASS002", "GRASS003" into the Integers
1,2,3 ? (aka getting rid of the "GRASS"-part of the string) ?

If you absolutely need to work with the dbf-driver, then I guess you best bet would be to open the dbf file in OpenOffice Calc and use its functions.

If you can switch over to SQLite, I think the ltrim function should do what you need.

More full-fledged SQL-backends obviously have more sophisticated functions.

Moritz

Hi Peter,

Following Morit´z suggestion, how about you use R on this task?

#The code below is to you read your dbf file
#so remove the # and include your full path/file name
#require(foreign)
#my.dbf<-read.dbf(“c:/temp/myfile.dbf”) #

#below we simulate a data.frame (it is a table)

my.dbf<-data.frame(cbind(var1=c(“GRASS001”,“GRASS002”,“GRASS003”)))
my.dbf

#below you have a code to “deparse” your variable of interest

my.dbf$var2_char<-substr(my.dbf$var1,6,999)
my.dbf

my.dbf$var2_int <-as.numeric(as.character(my.dbf$var2_char))
my.dbf

Cheers,

miltinho

brazil

2008/8/6, Moritz Lennert <mlennert@club.worldonline.be>:

On 06/08/08 15:09, peter.loewe@gmx.de wrote:

Hello list,

i am using GRASS 6.4svn to merge adjacent poylgons into larger units.
The merging is controlled by a column of type CHAR:

v.dissolve input=counties output=counties_merged_fips1 column=FIPS_1

results in dbmi: Protocol error ERROR: Cannot open select cursor:
SELECT cat, FIPS_1 FROM counties ORDER BY FIPS_1 ERROR: Unable to
open vector map <counties_fips1_22157@admin_borders> on topology
level 2 WARNING: Table <counties_fips1_22157> linked to vector map <counties_fips1_22157> does not exist ERROR: Vector map
<counties_fips1> not found in the current mapset

v.dissolve works correctly when applied to an INT column.

I assume this is a bugfeature -

v.dissolve is only a frontend script to v.reclass which needs ints…

string-based dissolving would be
great to have at some point.

+1

For now, does anybody have a (DBdriver-)SQL-hack to transmogrify
strings like “GRASS001”, “GRASS002”, “GRASS003” into the Integers
1,2,3 ? (aka getting rid of the “GRASS”-part of the string) ?

If you absolutely need to work with the dbf-driver, then I guess you best bet would be to open the dbf file in OpenOffice Calc and use its functions.

If you can switch over to SQLite, I think the ltrim function should do what you need.

More full-fledged SQL-backends obviously have more sophisticated functions.

Moritz


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

There is a long tread about this...

http://thread.gmane.org/gmane.comp.gis.grass.user/21875/focus=21887

In the end I was under the impression that v.dissolve did work with
string data, as Hamish wrote:
http://article.gmane.org/gmane.comp.gis.grass.user/21920

But, I'm not sure if the column has to be type varchar or something else?

Anyway, if you are using dbf database, just open it in openoffice
(calc or base) and add a neu integer column with the values you want
for dissolve

cheers
daniel

On Wed, Aug 6, 2008 at 1:40 PM, Milton Cezar Ribeiro
<miltinho.astronauta@gmail.com> wrote:

Hi Peter,

Following Morit´z suggestion, how about you use R on this task?

#The code below is to you read your dbf file
#so remove the # and include your full path/file name
#require(foreign)
#my.dbf<-read.dbf("c:/temp/myfile.dbf") #

#below we simulate a data.frame (it is a table)

my.dbf<-data.frame(cbind(var1=c("GRASS001","GRASS002","GRASS003")))
my.dbf

#below you have a code to "deparse" your variable of interest

my.dbf$var2_char<-substr(my.dbf$var1,6,999)
my.dbf

my.dbf$var2_int <-as.numeric(as.character(my.dbf$var2_char))
my.dbf

Cheers,

miltinho

brazil

2008/8/6, Moritz Lennert <mlennert@club.worldonline.be>:

On 06/08/08 15:09, peter.loewe@gmx.de wrote:

Hello list,

i am using GRASS 6.4svn to merge adjacent poylgons into larger units.
The merging is controlled by a column of type CHAR:

v.dissolve input=counties output=counties_merged_fips1 column=FIPS_1

results in dbmi: Protocol error ERROR: Cannot open select cursor:
SELECT cat, FIPS_1 FROM counties ORDER BY FIPS_1 ERROR: Unable to
open vector map <counties_fips1_22157@admin_borders> on topology
level 2 WARNING: Table <counties_fips1_22157> linked to vector map
<counties_fips1_22157> does not exist ERROR: Vector map
<counties_fips1> not found in the current mapset

v.dissolve works correctly when applied to an INT column.

I assume this is a bugfeature -

v.dissolve is only a frontend script to v.reclass which needs ints...

string-based dissolving would be
great to have at some point.

+1

For now, does anybody have a (DBdriver-)SQL-hack to transmogrify
strings like "GRASS001", "GRASS002", "GRASS003" into the Integers
1,2,3 ? (aka getting rid of the "GRASS"-part of the string) ?

If you absolutely need to work with the dbf-driver, then I guess you best
bet would be to open the dbf file in OpenOffice Calc and use its functions.

If you can switch over to SQLite, I think the ltrim function should do
what you need.

More full-fledged SQL-backends obviously have more sophisticated
functions.

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

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

Hello Milton,

thanks for that beautiful R-hack !
Since I am working on a minimal "bread and butter" machine I went for Moritz' solution but it's a neat idea to use R for the task.

Eventually, GIS-hacking should become part of the Olympics and you all should try to get medals :slight_smile:

Cheers,
Peter

-------- Original-Nachricht --------

Datum: Wed, 6 Aug 2008 13:40:35 -0300
Von: "Milton Cezar Ribeiro" <miltinho.astronauta@gmail.com>
An: "Moritz Lennert" <mlennert@club.worldonline.be>
CC: peter.loewe@gmx.de, grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] v.dissolve bugfeature / workaround needed

Hi Peter,

Following Morit´z suggestion, how about you use R on this task?

#The code below is to you read your dbf file
#so remove the # and include your full path/file name
#require(foreign)
#my.dbf<-read.dbf("c:/temp/myfile.dbf") #

#below we simulate a data.frame (it is a table)

my.dbf<-data.frame(cbind(var1=c("GRASS001","GRASS002","GRASS003")))
my.dbf

#below you have a code to "deparse" your variable of interest

my.dbf$var2_char<-substr(my.dbf$var1,6,999)
my.dbf

my.dbf$var2_int <-as.numeric(as.character(my.dbf$var2_char))
my.dbf

Cheers,

miltinho

brazil

2008/8/6, Moritz Lennert <mlennert@club.worldonline.be>:
>
> On 06/08/08 15:09, peter.loewe@gmx.de wrote:
>
>> Hello list,
>>
>> i am using GRASS 6.4svn to merge adjacent poylgons into larger units.
>> The merging is controlled by a column of type CHAR:
>>
>> v.dissolve input=counties output=counties_merged_fips1 column=FIPS_1
>>
>>
>> results in dbmi: Protocol error ERROR: Cannot open select cursor:
>> SELECT cat, FIPS_1 FROM counties ORDER BY FIPS_1 ERROR: Unable to
>> open vector map <counties_fips1_22157@admin_borders> on topology
>> level 2 WARNING: Table <counties_fips1_22157> linked to vector map
>> <counties_fips1_22157> does not exist ERROR: Vector map
>> <counties_fips1> not found in the current mapset
>>
>> v.dissolve works correctly when applied to an INT column.
>>
>> I assume this is a bugfeature -
>>
>
> v.dissolve is only a frontend script to v.reclass which needs ints...
>
> string-based dissolving would be
>> great to have at some point.
>>
>
> +1
>
>
>> For now, does anybody have a (DBdriver-)SQL-hack to transmogrify
>> strings like "GRASS001", "GRASS002", "GRASS003" into the Integers
>> 1,2,3 ? (aka getting rid of the "GRASS"-part of the string) ?
>>
>
> If you absolutely need to work with the dbf-driver, then I guess you
best
> bet would be to open the dbf file in OpenOffice Calc and use its
functions.
>
> If you can switch over to SQLite, I think the ltrim function should do
what
> you need.
>
> More full-fledged SQL-backends obviously have more sophisticated
functions.
>
> Moritz
> _______________________________________________
> grass-user mailing list
> grass-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>

--
Dr. Peter Löwe
<peter.loewe@gmx.de>

Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: http://www.gmx.net/de/go/messenger03

On 07/08/08 17:20, Peter Löwe wrote:

Hello Milton,

thanks for that beautiful R-hack !
Since I am working on a minimal "bread and butter" machine I went for Moritz' solution but it's a neat idea to use R for the task.

Eventually, GIS-hacking should become part of the Olympics and you all should try to get medals :slight_smile:

Actually, I stand corrected. Daniel was right: v.reclass does allow character columns and v.dissolve, therefore, does as well. I just tested with a map as it works with current svn trunk and and old pre-release 6.3:

> v.info -c NUTS2_2006
Displaying column types/names for database connection of layer 1:
INTEGER|cat
INTEGER|objectid
CHARACTER|cntr_code
INTEGER|stat_levl_
CHARACTER|nuts_id
DOUBLE PRECISION|shape_leng
DOUBLE PRECISION|shape_area

> v.dissolve in=NUTS2_2006 col=cntr_code out=countries

And I get a nice countries map...

So your error message is a bug:

results in dbmi: Protocol error ERROR: Cannot open select cursor:

>> SELECT cat, FIPS_1 FROM counties ORDER BY FIPS_1 ERROR: Unable to
>> open vector map <counties_fips1_22157@admin_borders> on topology
>> level 2 WARNING: Table <counties_fips1_22157> linked to vector map
>> <counties_fips1_22157> does not exist ERROR: Vector map
>> <counties_fips1> not found in the current mapset

Could you post the output of 'v.info -c counties' ?

Moritz

Hello Moritz and Peter,

I have the v.dissolve problem too. I'm running GRASS 6.4.svn (is there a way to tell what svn revision I'm using?) on Hardy Heron X86_64. Hope this info tells you something:

> v.dissolve input=alquist_priolo_eq_zones_mrg_ll83@PERMANENT output=efz layer=1 column=FaultName
Segmentation fault
dbmi: Protocol error
ERROR: Cannot open select cursor: SELECT cat, FaultName FROM
       alquist_priolo_eq_zones_mrg_ll83 ORDER BY FaultName
ERROR: Unable to open vector map <efz_24149@PERMANENT> on topology level 2
WARNING: Table <efz_24149> linked to vector map <efz_24149> does not exist
ERROR: Vector map <efz> not found in the current mapset

> v.info alquist_priolo_eq_zones_mrg_ll83
+----------------------------------------------------------------------------+
| Layer: alquist_priolo_eq_zones_mrg_ll83 |
| Mapset: PERMANENT |
| Location: CGS_SW_FaultLines |
| Database: /home/bobm/Data/Grass |
| Title: |
| Map scale: 1:1 |
| Map format: native |
| Name of creator: bobm |
| Organization: |
| Source date: Fri Nov 17 11:47:54 2006 |
|----------------------------------------------------------------------------|
| Type of Map: vector (level: 2) |
| |
| Number of points: 0 Number of areas: 2242 |
| Number of lines: 0 Number of islands: 788 |
| Number of boundaries: 4630 Number of faces: 0 |
| Number of centroids: 2224 Number of kernels: 0 |
| |
| Map is 3D: 0 |
| Number of dblinks: 1 |
| |
| Projection: Lambert Conformal Conic |
| N: 4959352.74991602 S: 3929916.63677083 |
| E: 341967.39773093 W: -438465.59887675 |
| |
| Digitization threshold: 0 |
| Comments: |
| |
+----------------------------------------------------------------------------+

> v.info -c alquist_priolo_eq_zones_mrg_ll83
Displaying column types/names for database connection of layer 1:
INTEGER|cat
DOUBLE PRECISION|ID
CHARACTER|COUNTY
CHARACTER|QUADNAME
CHARACTER|FaultName
CHARACTER|HistoricSR

Bob Moskovitz
Research Analyst I
Seismic Hazard Evaluation Project
California Geological Survey
http://gmw.consrv.ca.gov/shmp

CONFIDENTIALITY NOTICE: This communication is intended only for the use of the individual or entity to which it is addressed. This message contains information from the State of California, California Geological Survey, which may be privileged, confidential and exempt from disclosure under applicable law, including the Electronic Communications Privacy Act. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.

-----Original Message-----
From: grass-user-bounces@lists.osgeo.org
[mailto:grass-user-bounces@lists.osgeo.org]On Behalf Of Moritz Lennert
Sent: Thursday, August 07, 2008 8:45 AM
To: Peter Löwe
Cc: grass-user@lists.osgeo.org
Subject: Re: [GRASS-user] v.dissolve bugfeature / workaround needed

On 07/08/08 17:20, Peter Löwe wrote:
> Hello Milton,
>
> thanks for that beautiful R-hack !
> Since I am working on a minimal "bread and butter" machine
I went for Moritz' solution but it's a neat idea to use R for
the task.
>
> Eventually, GIS-hacking should become part of the Olympics
and you all should try to get medals :slight_smile:

Actually, I stand corrected. Daniel was right: v.reclass does allow
character columns and v.dissolve, therefore, does as well. I
just tested
with a map as it works with current svn trunk and and old
pre-release 6.3:

> v.info -c NUTS2_2006
Displaying column types/names for database connection of layer 1:
INTEGER|cat
INTEGER|objectid
CHARACTER|cntr_code
INTEGER|stat_levl_
CHARACTER|nuts_id
DOUBLE PRECISION|shape_leng
DOUBLE PRECISION|shape_area

> v.dissolve in=NUTS2_2006 col=cntr_code out=countries

And I get a nice countries map...

So your error message is a bug:

> results in dbmi: Protocol error ERROR: Cannot open select cursor:
>> >> SELECT cat, FIPS_1 FROM counties ORDER BY FIPS_1 ERROR:
Unable to
>> >> open vector map <counties_fips1_22157@admin_borders> on topology
>> >> level 2 WARNING: Table <counties_fips1_22157> linked to
vector map
>> >> <counties_fips1_22157> does not exist ERROR: Vector map
>> >> <counties_fips1> not found in the current mapset

Could you post the output of 'v.info -c counties' ?

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

Moskovitz, Bob pisze:

I have the v.dissolve problem too. I'm running GRASS 6.4.svn (is
there a way to tell what svn revision I'm using?)

In the directory with GRASS source code check the .svn/entries file. 4th
line from top carries the revision number.

v.dissolve input=alquist_priolo_eq_zones_mrg_ll83@PERMANENT
output=efz layer=1 column=FaultName

Segmentation fault

Does this happen with all vector maps? If not, please report to Trac and
provide the sample data to reproduce the problem (a location that
contains the PERMANENT mapset alone with only the problematic vector map
inside).

Maciek

--
Maciej Sieczka
www.sieczka.org

On Tue, Aug 12, 2008 at 4:56 AM, Maciej Sieczka <tutey@o2.pl> wrote:

Moskovitz, Bob pisze:

I have the v.dissolve problem too. I'm running GRASS 6.4.svn (is
there a way to tell what svn revision I'm using?)

In the directory with GRASS source code check the .svn/entries file. 4th
line from top carries the revision number.

Since yesterday it is also reported in the 6.4.svn source code in:

include/gis.h
...
#define GIS_H_VERSION "$Revision: XXXXX $"

Markus