[GRASS-user] DBMI-SQLite drive error when running i.segment.stats (with vector map creation)

Hello,

I’m running the following command:

i.segment.stats --overwrite --verbose map=angle_seg_uspo_angle_region_1_rank1@angle1
rasters=angle_ortho.1@angle1,angle_ortho.2@angle1,angle_ortho.3@angle1,angle_ortho.4@angle1
raster_statistics=min,max,mean,stddev,sum csvfile=/home/jd/Wales_GRASS/Angle/angle_isegstats
separator=comma vectormap=angle_isegstats

This code produces a complete .csv when run without the ‘vectormap’ option. However, when added in, I get the following errors:

Calculating geometry statistics
Calculating statistics for raster angle_ortho.1@angle1
Calculating statistics for raster angle_ortho.2@angle1
Calculating statistics for raster angle_ortho.3@angle1
Calculating statistics for raster angle_ortho.4@angle1
Creating vector map
DBMI-SQLite driver error:
Error in sqlite3_prepare():
unrecognized token: “.1_min”

ERROR: Error while executing: ‘CREATE TABLE angle_isegstats (cat int, area
double precision, perimeter double precision, compact_circle double
precision, fd double precision, angle_ortho.1_min double precision,
angle_ortho.1_max double precision, angle_ortho.1_mean double
precision, angle_ortho.1_stddev double precision, angle_ortho.1_sum
double precision, angle_ortho.2_min double precision,
angle_ortho.2_max double precision, angle_ortho.2_mean double
precision, angle_ortho.2_stddev double precision, angle_ortho.2_sum
double precision, angle_ortho.3_min double precision,
angle_ortho.3_max double precision, angle_ortho.3_mean double
precision, angle_ortho.3_stddev double precision, angle_ortho.3_sum
double precision, angle_ortho.4_min double precision,
angle_ortho.4_max double precision, angle_ortho.4_mean double
precision, angle_ortho.4_stddev double precision, angle_ortho.4_sum
double precision)’
Traceback (most recent call last):
File “/home/jd/.grass7/addons/scripts/i.segment.stats”, line 250, in
main()
File “/home/jd/.grass7/addons/scripts/i.segment.stats”, line 238, in main
gscript.run_command(‘db.execute’, input=insert_sql, quiet=True)
File “/usr/lib/grass70/etc/python/grass/script/core.py”, line 395, in run_command
return handle_errors(returncode, returncode, args, kwargs)
File “/usr/lib/grass70/etc/python/grass/script/core.py”, line 313, in handle_errors
returncode=returncode)
grass.exceptions.CalledModuleError: Module run None [‘db.execute’, ‘–q’, ‘input=/home/jd/Wales_GRASS/Angle/angle1/.tmp/jd-virtual-machine/6899.1’] ended with error
Process ended with non-zero return code 1. See errors in the (error) output.

I suspect this might be something to do with the length of the column name?

Any help would be much appreciated.

Thanks

James

angle_ortho.1_min double precision

I suspect that it is the point in the column name.

to verify, try to add such a column name in one of your vectors.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/DBMI-SQLite-drive-error-when-running-i-segment-stats-with-vector-map-creation-tp5291318p5291319.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I think that you’re correct.

v.db.addcolumn --verbose map=angle_region_1_poly@angle1 columns=test.test

gives:

Adding column <test.test> to the table
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near “.”: syntax error
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near “.”: syntax error
ERROR: Error while executing: ‘ALTER TABLE angle_region_1_poly ADD COLUMN test.test’
ERROR: Unable to add column <test.test>.

Given that the default output names created when multi band rasters are read into GRASS with r.in.gdal contain a ‘.’, and that these names can sometimes be used for labeling in vector operations (as I have described)…Is this something that can be rectified in the code of tools, or just something that should be worked around by the person using the tools?

I guess I could do this with a g.rename.

Thanks

James

···

On 18 October 2016 at 17:51, Helmut Kudrnovsky <hellik@web.de> wrote:

angle_ortho.1_min double precision

I suspect that it is the point in the column name.

to verify, try to add such a column name in one of your vectors.


best regards
Helmut

View this message in context: http://osgeo-org.1560.x6.nabble.com/DBMI-SQLite-drive-error-when-running-i-segment-stats-with-vector-map-creation-tp5291318p5291319.html
Sent from the Grass - Users mailing list archive at Nabble.com.


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

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

The “.” could be allowed if quoted identifiers were used, but that would be a quite invasive change and can have side effects on many other modules.

Furthermore quoted identifiers can be handled differently in the different DB backends, thus code complexity will increase.

In general it is also risky if the software alters your data (like renaming columns or even maps) at least if that behavior is not clearly documented…

Handling this in the code is at least not trivial as it either would require significant changes.

See also: https://trac.osgeo.org/grass/ticket/3071

Cheers

Stefan

···

I think that you’re correct.

v.db.addcolumn --verbose map=angle_region_1_poly@angle1 columns=test.test

gives:

Adding column <test.test> to the table
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near “.”: syntax error
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near “.”: syntax error
ERROR: Error while executing: ‘ALTER TABLE angle_region_1_poly ADD COLUMN test.test’
ERROR: Unable to add column <test.test>.

Given that the default output names created when multi band rasters are read into GRASS with r.in.gdal contain a ‘.’, and that these names can sometimes be used for labeling in vector operations (as I have described)…Is this something that can be rectified in the code of tools, or just something that should be worked around by the person using the tools?

I guess I could do this with a g.rename.

Thanks

James

On 18 October 2016 at 17:51, Helmut Kudrnovsky <hellik@web.de> wrote:

angle_ortho.1_min double precision

I suspect that it is the point in the column name.

to verify, try to add such a column name in one of your vectors.


best regards
Helmut

View this message in context: http://osgeo-org.1560.x6.nabble.com/DBMI-SQLite-drive-error-when-running-i-segment-stats-with-vector-map-creation-tp5291318p5291319.html
Sent from the Grass - Users mailing list archive at Nabble.com.


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

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

James Duffy wrote

I think that you're correct.

v.db.addcolumn --verbose map=angle_region_1_poly@angle1 columns=test.test

gives:

Adding column
<test.test>
to the table
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near ".": syntax error
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near ".": syntax error
ERROR: Error while executing: 'ALTER TABLE angle_region_1_poly ADD COLUMN
test.test'
ERROR: Unable to add column
<test.test>
.

Given that the default output names created when multi band rasters are
read into GRASS with r.in.gdal contain a '.', and that these names can
sometimes be used for labeling in vector operations (as I have
described)...Is this something that can be rectified in the code of tools,
or just something that should be worked around by the person using the
tools?

I guess I could do this with a g.rename.

Thanks

James

On 18 October 2016 at 17:51, Helmut Kudrnovsky &lt;

hellik@

&gt; wrote:

>angle_ortho.1_min double precision

I suspect that it is the point in the column name.

to verify, try to add such a column name in one of your vectors.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.
nabble.com/DBMI-SQLite-drive-error-when-running-i-segment-
stats-with-vector-map-creation-tp5291318p5291319.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list

grass-user@.osgeo

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

--
*James Duffy*
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

_______________________________________________
grass-user mailing list

grass-user@.osgeo

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

maybe open an enhancement ticket in track to add new separators for
multiband import in r.in.gdal.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/DBMI-SQLite-drive-error-when-running-i-segment-stats-with-vector-map-creation-tp5291318p5291397.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 19/10/16 10:42, Blumentrath, Stefan wrote:

The “.” could be allowed if quoted identifiers were used, but that would
be a quite invasive change and can have side effects on many other modules.

Furthermore quoted identifiers can be handled differently in the
different DB backends, thus code complexity will increase.

In general it is also risky if the software alters your data (like
renaming columns or even maps) at least if that behavior is not clearly
documented...

Even though I agree with this in principle, in the case at hand here (i.segment.stats) the issue is vector attribute column names based on raster names. I don't think that there is much risk there.

Handling this in the code is at least not trivial as it either would
require significant changes.

Again, for many cases this is very true. Here, I believe that a simple:

colname = colname.replace('.', '_')

is enough.

Implemented in r69707.

James, just reinstall once again and it should work.

Moritz