Re: [GRASS-user] v.dissolve and r.cost problems

2009-04-03 Thread Markus Neteler
On Thu, Apr 2, 2009 at 6:37 PM, Moritz Lennert
mlenn...@club.worldonline.be wrote:
 On 02/04/09 18:12, Moritz Lennert wrote:
 On 02/04/09 16:58, Markus Neteler wrote:
 On Thu, Apr 2, 2009 at 4:51 PM, Moritz Lennert
 On 02/04/09 16:00, Markus Neteler wrote:
 On Thu, Apr 2, 2009 at 1:43 PM, Markus Neteler nete...@osgeo.org
 On Wed, Apr 1, 2009 at 6:05 PM, Paolo Cavallini
 v.dissolve input=reg...@nuovo layer=1 column=REGIAO output=reg_diss
 dbmi: Protocol error
 ...
 Offlist we figured it out:
 If the REGIAO column field value is empty, then it fails.
...
 BAD happens when Null is found here.

 And that's arguably a correct behaviour as how should NULL be handled in
 such a comparison ? Don't know how it is dealt with in other DBMS...

Yes, I also don't know...

 So, before we fix this in any way, we should probably agree to how to
 handle it. One possible way would be to check for nulls and if there are any
 to assign a return value according to our choice as to where to sort nulls
 to. Don't know how to check for an uninitialised char variable in C, but I
 imagine that it should be possible.

 Actually, you should be able to check
 tbl-rows[*row1].values[cur_cmp_ocol].is_null

 and deal with the values accordingly, but from a casual glimpse I cannot
 find the possible values of is_null... I suppose 0 for false and 1 for true,
 but not sure...Use your example to check, with something like

 fprintf(stdout, row 1 null status = %i\n, 
 tbl-rows[*row1].values[cur_cmp_ocol].is_null);

echo SELECT cat, REGIAO FROM regiao ORDER BY REGIAO | db.select
D0/0: case DBF_CHAR: c1 = ALTO PORTUGAL, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = (null), c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 1
dbmi: Protocol error

Seems to be found.

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Moritz Lennert

On 02/04/09 22:22, Craig Leat wrote:

I am receiving the following error when patching two point vector maps:
v.patch -e in=SBC1,SBC2 out=SBC_0607
Patching vector map s...@craig...
DBMI-SQLite driver error:
Error in sqlite3_step():
SQL logic error or missing database

ERROR: Cannot insert new record: 'insert into SBC_0607 values ( 64510,
   'Dwelling', 'The Msunduzi', 37)'

The attribute tables look like this :
v.info -c SBC1
Displaying column types/names for database connection of layer 1:
INTEGER|cat
CHARACTER|CLASS_NAME
CHARACTER|LM
INTEGER|WARD

v.info -c SBC2
Displaying column types/names for database connection of layer 1:
INTEGER|cat
CHARACTER|CLASS_NAME
CHARACTER|LM
INTEGER|WARD

I have checked disk space and file size of the sqlite db - no problems
there. Any ideas why sqlite chokes on cat 64510?


What does v.db.connect -p show for each of the two maps ?

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


Re: [GRASS-user] displaying many thematic maps from one vector dataset

2009-04-03 Thread Moritz Lennert

On 03/04/09 00:23, Vishal Mehta wrote:

Hello all,

I am better at GRASS raster capabilities than with GRASS vector 
handling, so I am writing to get your help.


What I want to do is this:
1. I will have one vector dataset of watersheds. Each record is a 
polygon, an individual watershed. There are, apart from the usual cat 
fields, 52 attribute columns. Each attribute column is modeled weekly 
snow depth.


2. I need to automate the display and export to png of 52 thematic 
images - one for each week/column - keeping the color scheme constant 
throughout. Then all of the images will be packaged into a kml animation.


I know how to do the above starting from a stack of GRASS rasters, but 
am not quickly getting a handle on displaying GRASS vectors 
consistently. I've tried d.vect and d.vect.thematic. I havent tried 
d.thematic.area yet.


The main issues are that I dont know:
- how to assign a constant color scheme  to each map (that spans the min 
and max of all columns); i guess i was looking for something as simple 
as setting color rules like with raster data.


If you want constant class breaks, i.e. the same class number and 
amplitudes linked to the same colors, then you can just manually provide 
breaks and colors in d.thematic.area.


 
- how to refer to each attribute column by column number in a loop 
(d.vect.thematic and d.thematic.area  seem to need column name as attribute)


(assuming you are in a *nix environment with a shell):
for col in `v.info -c MapName`; do d.thematic.area  column=$col; done
(note the backticks around the v.info command))

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Craig Leat
Moritz wrote:
 What does v.db.connect -p show for each of the two maps ?

v.db.connect -p map=SBC1
Vector map s...@craig is connected by:
layer 1 table SBC1 in database
/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db through driver
sqlite with key cat

v.db.connect -p map=SBC2
Vector map s...@craig is connected by:
layer 1 table SBC2 in database
/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db through driver
sqlite with key cat

All looks fine to me. BTW v.patch works if I drop the -e option, but I
need the attributes.

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


Re: [GRASS-user] meaning of r.param.scale features colours?

2009-04-03 Thread Markus Neteler
On Fri, Apr 3, 2009 at 12:28 AM, Paolo Cavallini cavall...@faunalia.it wrote:
 Hi all.
 I cannot find the meaning of the colours (values) produced by
 r.param.scale features; it is quite obvious that reds are peaks, green
 saddles, but I cannot find a full description. Wouldn't it be good to
 put it on the manpage?

Sure, done (screenshot added).

To find out:

# Spearfish
g.region rast=elevation.10m -p
r.param.scale in=elevation.10m output=morphology param=feature size=9
d.mon x0
d.rast.leg morphology

# GRASS 6.3
r.cats morphology

# GRASS 6.4+,7
r.category morphology

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


Re: [GRASS-user] v.dissolve and r.cost problems

2009-04-03 Thread Moritz Lennert

On 03/04/09 08:43, Markus Neteler wrote:

On Thu, Apr 2, 2009 at 6:37 PM, Moritz Lennert
mlenn...@club.worldonline.be wrote:

On 02/04/09 18:12, Moritz Lennert wrote:

On 02/04/09 16:58, Markus Neteler wrote:

On Thu, Apr 2, 2009 at 4:51 PM, Moritz Lennert

On 02/04/09 16:00, Markus Neteler wrote:

On Thu, Apr 2, 2009 at 1:43 PM, Markus Neteler nete...@osgeo.org

On Wed, Apr 1, 2009 at 6:05 PM, Paolo Cavallini

v.dissolve input=reg...@nuovo layer=1 column=REGIAO output=reg_diss
dbmi: Protocol error

...

Offlist we figured it out:
If the REGIAO column field value is empty, then it fails.

...

BAD happens when Null is found here.

And that's arguably a correct behaviour as how should NULL be handled in
such a comparison ? Don't know how it is dealt with in other DBMS...


Yes, I also don't know...


So, before we fix this in any way, we should probably agree to how to
handle it. One possible way would be to check for nulls and if there are any
to assign a return value according to our choice as to where to sort nulls
to. Don't know how to check for an uninitialised char variable in C, but I
imagine that it should be possible.

Actually, you should be able to check
tbl-rows[*row1].values[cur_cmp_ocol].is_null

and deal with the values accordingly, but from a casual glimpse I cannot
find the possible values of is_null... I suppose 0 for false and 1 for true,
but not sure...Use your example to check, with something like

fprintf(stdout, row 1 null status = %i\n, 
tbl-rows[*row1].values[cur_cmp_ocol].is_null);


echo SELECT cat, REGIAO FROM regiao ORDER BY REGIAO | db.select
D0/0: case DBF_CHAR: c1 = ALTO PORTUGAL, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 0
D0/0: case DBF_CHAR: c1 = (null), c2 = ALTO PORTUGAL
D0/0: case DBF_CHAR: row 1 null status = 1
dbmi: Protocol error

Seems to be found.


Ok, try the attached diff to grass6 head.

It implements the same behaviour for all data types: null values are 
sorted to the end.


Moritz
Index: dbfexe.c
===
--- dbfexe.c	(révision 36571)
+++ dbfexe.c	(copie de travail)
@@ -499,32 +499,47 @@
 
 tbl = (db.tables[cur_cmp_table]);
 
-switch (tbl-cols[cur_cmp_ocol].type) {
-case DBF_CHAR:
-	c1 = tbl-rows[*row1].values[cur_cmp_ocol].c;
-	c2 = tbl-rows[*row2].values[cur_cmp_ocol].c;
-	return (strcmp(c1, c2));
-	break;
-case DBF_INT:
-	i1 = tbl-rows[*row1].values[cur_cmp_ocol].i;
-	i2 = tbl-rows[*row2].values[cur_cmp_ocol].i;
-	if (i1  i2)
-	return -1;
-	if (i1  i2)
+if (tbl-rows[*row1].values[cur_cmp_ocol].is_null) {
+	if (tbl-rows[*row2].values[cur_cmp_ocol].is_null) {
+	return 0;
+	}
+	else {
 	return 1;
-	return 0;
-	break;
-case DBF_DOUBLE:
-	d1 = tbl-rows[*row1].values[cur_cmp_ocol].d;
-	d2 = tbl-rows[*row2].values[cur_cmp_ocol].d;
-	if (d1  d2)
+	}
+}
+else {
+	if (tbl-rows[*row2].values[cur_cmp_ocol].is_null) {
 	return -1;
-	if (d1  d2)
-	return 1;
-	return 0;
-	break;
+	}
+	else {
+	switch (tbl-cols[cur_cmp_ocol].type) {
+	case DBF_CHAR:
+		c1 = tbl-rows[*row1].values[cur_cmp_ocol].c;
+		c2 = tbl-rows[*row2].values[cur_cmp_ocol].c;
+		return (strcmp(c1, c2));
+		break;
+	case DBF_INT:
+		i1 = tbl-rows[*row1].values[cur_cmp_ocol].i;
+		i2 = tbl-rows[*row2].values[cur_cmp_ocol].i;
+		if (i1  i2)
+		return -1;
+		if (i1  i2)
+		return 1;
+		return 0;
+		break;
+	case DBF_DOUBLE:
+		d1 = tbl-rows[*row1].values[cur_cmp_ocol].d;
+		d2 = tbl-rows[*row2].values[cur_cmp_ocol].d;
+		if (d1  d2)
+		return -1;
+		if (d1  d2)
+		return 1;
+		return 0;
+		break;
+	}
+	return 0;
+	}
 }
-return 0;
 }
 
 static int cmp_row_desc(const void *pa, const void *pb)
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] v.dissolve and r.cost problems

2009-04-03 Thread Markus Neteler
On Fri, Apr 3, 2009 at 9:20 AM, Moritz Lennert
mlenn...@club.worldonline.be wrote:
...
 Ok, try the attached diff to grass6 head.

 It implements the same behaviour for all data types: null values are sorted
 to the end.

Perfect, this works. Please submit.

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Moritz Lennert

On 03/04/09 09:10, Craig Leat wrote:

Moritz wrote:

What does v.db.connect -p show for each of the two maps ?


v.db.connect -p map=SBC1
Vector map s...@craig is connected by:
layer 1 table SBC1 in database
/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db through driver
sqlite with key cat

v.db.connect -p map=SBC2
Vector map s...@craig is connected by:
layer 1 table SBC2 in database
/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db through driver
sqlite with key cat


And what about v.info -c / v.db.connect -p SBC_0607 ?
db.connect -p ?

Also what do you see when you run

sqlite3 /home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db

?

And then .tables and/or .schema TableName at the command prompt ?

Maybe you can also set

g.gisenv set=DEBUG=3

and see if you get any useful debug info.

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Craig Leat
Moritz,

Thanks for the suggestions. I think I've got something:

Craig Leat wrote:
 I am receiving the following error when patching two point vector maps:
 v.patch -e in=SBC1,SBC2 out=SBC_0607
 Patching vector map s...@craig...
 DBMI-SQLite driver error:
 Error in sqlite3_step():
 SQL logic error or missing database

 ERROR: Cannot insert new record: 'insert into SBC_0607 values ( 64510,
   'Dwelling', 'The Msunduzi', 37)'

Notice that the second and third columns contain strings.

db.describe -c table=SBC1 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 4
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: CLASS_NAME:CHARACTER:1
Column 3: LM:CHARACTER:1
Column 4: WARD:INTEGER:20

Second and third columns are type CHARACTER with length=1 ???

How did this happen, as SBC1 was generated by:
g.copy v=SBC_0506,SBC1

and then modified with a few runs of v.db.dropcol map=SBC1 layer=1 col=

Columns CLASS_NAME and LM are correctly specified in the original
vector (SBC_0506):
db.describe -c table=SBC_0506 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 21
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: CLASS:DOUBLE PRECISION:20
Column 3: CLASS_NAME:CHARACTER:20
Column 4: SOURCE:CHARACTER:15
Column 5: PROV:CHARACTER:25
Column 6: MUNIC:CHARACTER:50
Column 7: ESKOM_FSA:CHARACTER:25
Column 8: TRIBAL_AUT:CHARACTER:50
Column 9: PROCLAIMED:CHARACTER:5
Column 10: INT_ERVEN:CHARACTER:5
Column 11: INT_FARM:CHARACTER:5
Column 12: INT_FARMPN:CHARACTER:5
Column 13: INT_AGRHLD:CHARACTER:5
Column 14: INT_PARK:CHARACTER:5
Column 15: INT_TA:CHARACTER:5
Column 16: SUB_HV_DES:CHARACTER:25
Column 17: SUB_MV_DES:CHARACTER:25
Column 18: TRNSFMR_NM:CHARACTER:25
Column 19: SOURCE_IMG:CHARACTER:20
Column 20: LM:CHARACTER:20
Column 21: WARD:INTEGER:20

It seems to me that either g.copy or v.db.dropcol has messed up
columns 3 and 20 (in the original vector). Can I change the length of
columns 2 and 3 in SBC1 and SBC2 or maybe I can copy the columns to
new columns with the correct length?

Thanks

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


Re: [GRASS-user] v.dissolve and r.cost problems

2009-04-03 Thread Moritz Lennert

On 03/04/09 09:31, Markus Neteler wrote:

On Fri, Apr 3, 2009 at 9:20 AM, Moritz Lennert
mlenn...@club.worldonline.be wrote:
...

Ok, try the attached diff to grass6 head.

It implements the same behaviour for all data types: null values are sorted
to the end.


Perfect, this works. Please submit.


Done, in trunk, devel6 and release64.

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


Re: [GRASS-user] meaning of r.param.scale features colours?

2009-04-03 Thread Hamish

 I cannot find the meaning of the colours (values) produced
 by r.param.scale features;

G r.category elev.features
0   
1   Planar
2   Pit
3   Channel
4   Pass (saddle)
5   Ridge
6   Peak


and
G d.legend elev.features


Hamish



  

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


Re: [GRASS-user] v.dissolve and r.cost problems

2009-04-03 Thread Markus Neteler
Paolo,

On Fri, Apr 3, 2009 at 10:04 AM, Moritz Lennert
mlenn...@club.worldonline.be wrote:
 On 03/04/09 09:31, Markus Neteler wrote:
 On Fri, Apr 3, 2009 at 9:20 AM, Moritz Lennert
...
 It implements the same behaviour for all data types: null values are
 sorted to the end.

 Perfect, this works. Please submit.

 Done, in trunk, devel6 and release64.

I have retried your command:
v.dissolve input=regiao layer=1 column=REGIAO output=reg_diss

now it dissolves the map as expected.
Also backported to 6.3 if that helps for you.

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


Re: [GRASS-user] Why v.extract produces columns of type CHARACTER?

2009-04-03 Thread Markus Neteler
On Wed, Jan 14, 2009 at 4:59 AM, Nikos Alexandris
nikos.alexand...@felis.uni-freiburg.de wrote:
 The columns produces by v.extract are of type CHARACTER and v.dissolve
 does not like this. It's an old issue.

Just for the record: Fixed today (it liked it already unless and empty
char field was found which was fixed by Moritz today in the DBF driver).

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


Re: [GRASS-user] problems with i.rectify

2009-04-03 Thread Martina Schäfer

Hi again!

I installed GRASS 6.4 and first I got the same error. Then, I tried with 
defining a new group and subgroup in the XY mapset (not using the one 
that is created when importing) and with that it worked!! However, I 
also tried using wxpython, which looks neat, but there I get the error 
message that the group does not exist (but it certainly does).


Best,
Martina




Markus Neteler skrev:

hi Martina,

On Thu, Apr 2, 2009 at 9:28 AM, Martina Schäfer
martina.scha...@ebc.uu.se wrote:
  

Hello Markus,

thanks for the reply! And thanks for the tip on i.orto.photo, I will read
through your article!


I've followed the instructions
and everything's working fine except that the red band is not included.
In
the output it says :
Rectified input file NN1_2.red will be saved as NN1_2.red 1257



I see a suspicious white space before 1257.
Where does it come from? Could it be that it crept
in when defining the group?

  

Well, the space was my fault and a typing mistake, it really says
NN1_2.red1257, so no error there.



ah ok, perfect.

  

In the mapset there is a group/ directory in which the
group is defined (ASCII file). The easiest way is to check
there/fix if the red channel was defined properly.

  

I looked in the group folder and found a file REF where all bands are
properly named. Was that the file you meant?



Yes, fine.

  

The group is defined in the XY location. In the projected location it does
not exist prior to rectifying.



BTW: which GRASS version and which operating system?

  

I'm using GRASS 6.3. downloaded from http://grass.bologna.enea.it/ on Mac OS
X 10.5.6



I recall that we fixed some issues later. Could you upgrade to 6.4RC3
instead?
http://grass.osgeo.org/download/index.php#g64x

If it still fails we may be able to fix it for 6.4.0 final.

best
Markus

  

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Moritz Lennert

On 03/04/09 10:03, Craig Leat wrote:

Moritz,

Thanks for the suggestions. I think I've got something:

Craig Leat wrote:

I am receiving the following error when patching two point vector maps:
v.patch -e in=SBC1,SBC2 out=SBC_0607
Patching vector map s...@craig...
DBMI-SQLite driver error:
Error in sqlite3_step():
SQL logic error or missing database

ERROR: Cannot insert new record: 'insert into SBC_0607 values ( 64510,
  'Dwelling', 'The Msunduzi', 37)'


Notice that the second and third columns contain strings.

db.describe -c table=SBC1 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 4
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: CLASS_NAME:CHARACTER:1
Column 3: LM:CHARACTER:1
Column 4: WARD:INTEGER:20

Second and third columns are type CHARACTER with length=1 ???

How did this happen, as SBC1 was generated by:
g.copy v=SBC_0506,SBC1

and then modified with a few runs of v.db.dropcol map=SBC1 layer=1 col=

Columns CLASS_NAME and LM are correctly specified in the original
vector (SBC_0506):
db.describe -c table=SBC_0506 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 21
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: CLASS:DOUBLE PRECISION:20
Column 3: CLASS_NAME:CHARACTER:20
Column 4: SOURCE:CHARACTER:15
Column 5: PROV:CHARACTER:25
Column 6: MUNIC:CHARACTER:50
Column 7: ESKOM_FSA:CHARACTER:25
Column 8: TRIBAL_AUT:CHARACTER:50
Column 9: PROCLAIMED:CHARACTER:5
Column 10: INT_ERVEN:CHARACTER:5
Column 11: INT_FARM:CHARACTER:5
Column 12: INT_FARMPN:CHARACTER:5
Column 13: INT_AGRHLD:CHARACTER:5
Column 14: INT_PARK:CHARACTER:5
Column 15: INT_TA:CHARACTER:5
Column 16: SUB_HV_DES:CHARACTER:25
Column 17: SUB_MV_DES:CHARACTER:25
Column 18: TRNSFMR_NM:CHARACTER:25
Column 19: SOURCE_IMG:CHARACTER:20
Column 20: LM:CHARACTER:20
Column 21: WARD:INTEGER:20

It seems to me that either g.copy or v.db.dropcol has messed up
columns 3 and 20 (in the original vector). 


If you can reproduce this, especially with the GRASS demo data, then 
please file a bug report.



Can I change the length of
columns 2 and 3 in SBC1 and SBC2 or maybe I can copy the columns to
new columns with the correct length?


AFAIK, sqlite does not support alter column statements, but I think you 
can change column types in sqlitebrowser (don't know how they implement 
this). But you can obviously do it via copying.


SQLite does not really enforce column types (unless you tell it 
explicitely to do so), so normally you can put whatever you want into 
whatever column. This does sometimes create problems with GRASS' 
internal SQL type checks.


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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Markus Neteler
On Fri, Apr 3, 2009 at 10:59 AM, Moritz Lennert
mlenn...@club.worldonline.be wrote:
 On 03/04/09 10:03, Craig Leat wrote:
...
 Can I change the length of
 columns 2 and 3 in SBC1 and SBC2 or maybe I can copy the columns to
 new columns with the correct length?

 AFAIK, sqlite does not support alter column statements,

Right:http://www.sqlite.org/omitted.html

See the script v.db.renamecol
- # some tricks

how to potentially work around (create new column, transfer content).

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


Re: [GRASS-user] meaning of r.param.scale features colours?

2009-04-03 Thread Paolo Cavallini
Hamish ha scritto:

 G r.category elev.features

Thanks a lot. Perhaps this info could be put in the man page?
All the best.
-- 
Paolo Cavallini: http://faunalia.it/pc
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] v.dissolve and r.cost problems

2009-04-03 Thread Paolo Cavallini
Markus Neteler ha scritto:
 now it dissolves the map as expected.
 Also backported to 6.3 if that helps for you.

Thanks a lot to all!
-- 
Paolo Cavallini: http://faunalia.it/pc
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Craig Leat
I have a problem with v.db.dropcol, it's changing the length of columns.

db.describe -c table=SBC1 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 6
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: CLASS_NAME:CHARACTER:1
Column 3: LM:CHARACTER:1
Column 4: WARD:INTEGER:20
Column 5: building:CHARACTER:20
Column 6: LM_name:CHARACTER:20

v.db.dropcol map=SBC1 col=CLASS_NAME

db.describe -c table=SBC1 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 5
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: LM:CHARACTER:1
Column 3: WARD:INTEGER:20
Column 4: building:CHARACTER:1
Column 5: LM_name:CHARACTER:1

building and LM_name have changed from length=20 to length=1

I'll test with Spearfish and update GRASS before reporting a bug, but
this may take some time. First I have to finish this job with a broken
v.db.dropcol. It's time to play with sqlitebrowser...

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Moritz Lennert

On 03/04/09 11:34, Craig Leat wrote:

I have a problem with v.db.dropcol, it's changing the length of columns.

db.describe -c table=SBC1 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 6
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: CLASS_NAME:CHARACTER:1
Column 3: LM:CHARACTER:1
Column 4: WARD:INTEGER:20
Column 5: building:CHARACTER:20
Column 6: LM_name:CHARACTER:20

v.db.dropcol map=SBC1 col=CLASS_NAME

db.describe -c table=SBC1 driver=sqlite
database=/home/craig/GIS/grassdata/uMDM_ll/craig/sqlite.db
ncols: 5
nrows: 197842
Column 1: cat:INTEGER:20
Column 2: LM:CHARACTER:1
Column 3: WARD:INTEGER:20
Column 4: building:CHARACTER:1
Column 5: LM_name:CHARACTER:1

building and LM_name have changed from length=20 to length=1


Don't have time to look into this now, but it must be a problem in the 
special sqlite implementation in that script:


if [ $driver = sqlite ] ; then
#echo Using special trick for SQLite
# http://www.sqlite.org/faq.html#q13
v.info --q -c map=$GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d'|' 
-f1,2 | grep -v |${col}$  $TMP.coldesc

# need to revert order:
cat $TMP.coldesc | cut -d'|' -f1  $TMP.coltypes
cat $TMP.coldesc | cut -d'|' -f2  $TMP.colnames
COLDEF=`paste -d' ' $TMP.colnames $TMP.coltypes | tr '\n' 
',' | sed 's+,$++g'`

COLNAMES=`cat $TMP.colnames | tr '\n' ',' | sed 's+,$++g'`
echo BEGIN TRANSACTION;
CREATE TEMPORARY TABLE ${table}_backup(${COLDEF});
INSERT INTO ${table}_backup SELECT ${COLNAMES} FROM ${table};
DROP TABLE ${table};
CREATE TABLE ${table}(${COLDEF});
INSERT INTO ${table} SELECT ${COLNAMES} FROM ${table}_backup;
DROP TABLE ${table}_backup;
COMMIT;  $TMP
db.execute input=$TMP

You could try the individual steps and see where the problem comes from.



I'll test with Spearfish and update GRASS before reporting a bug, but
this may take some time. First I have to finish this job with a broken
v.db.dropcol. It's time to play with sqlitebrowser...


You can also try this:
https://addons.mozilla.org/en-US/firefox/addon/5817

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


[GRASS-user] Dem extraction

2009-04-03 Thread Raphael Saldanha
Hi!

I would like to know how can I extract a DEM from an Ikonos Stereo Image
with control points. I'm completely newbie with this... What books,
articles, materials I must read? And can GRASS do this?

King regards,

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


Re: [GRASS-user] Error in sqlite3_step()

2009-04-03 Thread Craig Leat
Moritz Lennert wrote:
 Don't have time to look into this now, but it must be a problem in the
 special sqlite implementation in that script:

 if [ $driver = sqlite ] ; then
#echo Using special trick for SQLite
# http://www.sqlite.org/faq.html#q13
v.info --q -c map=$GIS_OPT_MAP layer=$GIS_OPT_LAYER | cut -d'|' -f1,2
 | grep -v |${col}$  $TMP.coldesc
# need to revert order:
cat $TMP.coldesc | cut -d'|' -f1  $TMP.coltypes
cat $TMP.coldesc | cut -d'|' -f2  $TMP.colnames
COLDEF=`paste -d' ' $TMP.colnames $TMP.coltypes | tr '\n' ',' |
 sed 's+,$++g'`
COLNAMES=`cat $TMP.colnames | tr '\n' ',' | sed 's+,$++g'`
 echo BEGIN TRANSACTION;
 CREATE TEMPORARY TABLE ${table}_backup(${COLDEF});
 INSERT INTO ${table}_backup SELECT ${COLNAMES} FROM ${table};
 DROP TABLE ${table};
 CREATE TABLE ${table}(${COLDEF});
 INSERT INTO ${table} SELECT ${COLNAMES} FROM ${table}_backup;
 DROP TABLE ${table}_backup;
 COMMIT;  $TMP
 db.execute input=$TMP

My execute statement looks like this:
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE SBC2_backup(cat INTEGER,LM CHARACTER,WARD
INTEGER,CLASS_NAME CHARACTER);
INSERT INTO SBC2_backup SELECT cat,LM,WARD,CLASS_NAME FROM SBC2;
DROP TABLE SBC2;
CREATE TABLE SBC2(cat INTEGER,LM CHARACTER,WARD INTEGER,CLASS_NAME CHARACTER);
INSERT INTO SBC2 SELECT cat,LM,WARD,CLASS_NAME FROM SBC2_backup;
DROP TABLE SBC2_backup;
COMMIT;

Why does v.db.dropcol define a type CHARACTER when sqlite3 supports
(NULL, INTEGER, REAL, TEXT, BLOB)?

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


[GRASS-user] Please contribute to Gallery @ OSGeo

2009-04-03 Thread Markus Neteler
Hi,

please upload your cool FOSS4G screenshots to:
http://gallery.osgeo.org/

GRASS needs to be well represented of course :)

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


Re: [GRASS-user] displaying many thematic maps from one vector dataset

2009-04-03 Thread Vishal Mehta
A couple of strange behaviors with a test vector dataset whose columns are
population projections every 5 years:
I ran the following script below but:
1. I see it working ok on the x0 monitor; but the output png files are all
blank..
2. and i get messages while the script is running that include 'segmentation
fault' but not on EVERY iteration of the loop..

-script---
#!/bin/bash
#generate 5yr interval thematic pngs of low series PPIC population
projectiosn
yr=2010
while [ $yr -lt 2105 ] ; do

#actions here
echo yr is $yr 

d.thematic.area map=CountyPop column=pc$yr breaks=20,40,60
colors=cyan,blue,yellow,red
d.out.file output=pop$yr format=png
#
yr=$((yr+5))
done
messages while running above script-

---
yr is 2020
Segmentation fault
Saving display from Monitor: [x0] to pop2020.png.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2025
Segmentation fault
Saving display from Monitor: [x0] to pop2025.png.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2030
Segmentation fault
Saving display from Monitor: [x0] to pop2030.png.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2035
Saving display from Monitor: [x0] to pop2035.png.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2040
Saving display from Monitor: [x0] to pop2040.png.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2045
Saving display from Monitor: [x0] to pop2045.png.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
--

On Thu, Apr 2, 2009 at 11:54 PM, Moritz Lennert 
mlenn...@club.worldonline.be wrote:

 On 03/04/09 00:23, Vishal Mehta wrote:

 Hello all,

 I am better at GRASS raster capabilities than with GRASS vector handling,
 so I am writing to get your help.

 What I want to do is this:
 1. I will have one vector dataset of watersheds. Each record is a polygon,
 an individual watershed. There are, apart from the usual cat fields, 52
 attribute columns. Each attribute column is modeled weekly snow depth.

 2. I need to automate the display and export to png of 52 thematic images
 - one for each week/column - keeping the color scheme constant throughout.
 Then all of the images will be packaged into a kml animation.

 I know how to do the above starting from a stack of GRASS rasters, but am
 not quickly getting a handle on displaying GRASS vectors consistently. I've
 tried d.vect and d.vect.thematic. I havent tried d.thematic.area yet.

 The main issues are that I dont know:
 - how to assign a constant color scheme  to each map (that spans the min
 and max of all columns); i guess i was looking for something as simple as
 setting color rules like with raster data.


 If you want constant class breaks, i.e. the same class number and
 amplitudes linked to the same colors, then you can just manually provide
 breaks and colors in d.thematic.area.

   - how to refer to each attribute column by column number in a loop
 (d.vect.thematic and d.thematic.area  seem to need column name as attribute)


 (assuming you are in a *nix environment with a shell):
 for col in `v.info -c MapName`; do d.thematic.area  column=$col; done
 (note the backticks around the v.info command))

 Moritz




-- 
Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user