[GRASS-user] Square root in SQL Builder
Thiago Statella
t.statella at outlook.com
Wed Jan 31 04:22:34 PST 2024
Thank you guys, I’ll try that!
Atenciosamente,
--
Dr. Thiago Statella, Professor Titular
Instituto Federal de Educação, Ciência e Tecnologia de São Paulo - IFSP
Campus Presidente Epitácio
http://lattes.cnpq.br/8559753273123798
https://sites.google.com/view/statella
Em 30 de jan. de 2024, à(s) 20:09, Edouard Choinière <e.chs at outlook.com> escreveu:
Math functions in SQLite are available when SQLite’s amalgamation is compiled with
-DSQLITE_ENABLE_MATH_FUNCTIONS
However, since sqlite3 3.35, in March 2021, that option is on by default. I did a quick check with the latest released Ubuntu docker image for grass (so you could compare), and sqrt seems to work. Python has this enabled too for versions since April 2021, including back ported versions of Python 3.8 https://github.com/python/cpython/issues/86852, so there’s no reason it shouldn’t work.
echoix /workspace/grass (main) $ docker run -it osgeo/grass-gis:releasebranch_8_3-ubuntu bash
root at 83c468d748e4:/grassdb# grass
Starting GRASS GIS...
WARNING: It appears that the X Windows system is not active.
A graphical based user interface is not supported.
(DISPLAY variable is not set.)
Switching to text based interface mode.
__________ ___ __________ _______________
/ ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
/ / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
/ /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
\____/_/ |_/_/ |_/____/____/ \____/___//____/
Welcome to GRASS GIS 8.3.2dev (aeb4081)
GRASS GIS homepage: https://grass.osgeo.org
This version running through: Bash Shell (/bin/bash)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
Start the GUI with: g.gui wxpython
When ready to quit enter: exit
GRASS world_latlong_wgs84/PERMANENT:grassdb > sqlite3
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .version
SQLite 3.37.2 2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5dalt1
zlib version 1.2.11
gcc-11.4.0
sqlite> .exit
GRASS world_latlong_wgs84/PERMANENT:grassdb > db.select sql="select sqrt(2)"
sqrt(2)
1.4142135623731
GRASS world_latlong_wgs84/PERMANENT:grassdb >
You could check your versions, and come back if they are recent enough and should have them enabled, but aren’t. A little bit more info on your environment might be needed to fully understand in that case
Have a great day!
Edouard Choinière
Le 30 janv. 2024 à 04:41, Markus Neteler <neteler at osgeo.org> a écrit :
Hi Thiago,
On Tue, Jan 30, 2024 at 1:05 AM Thiago Statella via grass-user
<grass-user at lists.osgeo.org> wrote:
Hi everyone!
I need to populate a column in attribute table based on the square root of entries from another column.
I tried the field calculator with no success. It seams that SQRT function is not supported by SQLite driver.
Any help would be highly appreciated.
Functionalities like sqrt() or log() are not available in base SQLite
(an issue unrelated to GRASS GIS). You will have to install an SQLite extension.
See the v.db.update manual page and these wiki pages:
- https://grasswiki.osgeo.org/wiki/Build_SQLite_extension_on_Linux
- https://grasswiki.osgeo.org/wiki/Build_SQLite_extension_on_windows
Regards,
Markus
--
Markus Neteler, PhD
https://www.mundialis.de - company
https://grass.osgeo.org - FOSS
https://neteler.org - blog & freelancing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20240131/5b2a52d5/attachment-0001.htm>
More information about the grass-user
mailing list