Questions tagged [grass.script]

The Python scripting library for GRASS

Filter by
Sorted by
Tagged with
1 vote
1 answer
45 views

Looping GRASS "v.extract" in python

I have a multipolygon shapefile representing different cities. I am trying to loop the "v.extract" GRASS command through the different polygons via the Python interface. This is the code I ...
okapina's user avatar
  • 103
0 votes
0 answers
21 views

Viewing Errors from in pygrass

I am running using grass-session to run grass within a python environment on some short lived AWS servers. I am getting some errors from running r.sim.water, but I can't see what they are because they ...
sobmortin's user avatar
2 votes
1 answer
243 views

How to use Python packages (GeoPandas, rioxarray) inside GRASS Python scripts?

I want to combine the functionality of GRASS GIS with other Python packages such as GeoPandas and rioxarray. My OS is Windows. It is possible to import other standard packages such as numpy and Pandas....
pittyplaetsch's user avatar
0 votes
0 answers
36 views

Load GRASS raster layer in QGIS, with Python console

Is there any suitable set of Python commands that I could use to load GRASS raster layer in QGIS Python console? I tried this simple code: from qgis.core import QgsRasterLayer from PyQt5.QtCore import ...
pclastre's user avatar
0 votes
1 answer
120 views

How to process multiple GRASS GIS jobs with different regions in parallel?

I want to send requests from a web frontend to GRASS GIS. I am currently using the Python Web Framework FastAPI for communication between the frontend and GRASS GIS. I built the API as follows: First ...
Jonas Frei's user avatar
2 votes
2 answers
232 views

PyGRASS error: Could not load grass_gis.8.2

In PyGRASS I can only import objects from the module modules: from grass_session import Session from grass.pygrass.modules import Module, MultiModule, ParallelModuleQueue print(Module) If I'm trying ...
Jonas Frei's user avatar
0 votes
1 answer
151 views

How to set GRASS GIS environment variables in MacOS?

I'm trying to use grass.script and grass_session in a standalone python script on my MacOS device, but I always get error messages that tells me specific environment variables aren't set in the right ...
Jonas Frei's user avatar
3 votes
1 answer
138 views

GRASS GIS: Execute SQL query and save output

I'm trying to find a way in GRASS GIS to execute a complex SQL query (with JOINs) and save it. SELECT a.id, a.geom FROM schema01.table01 a JOIN schema01.table02 b ON a.geom && b.geom AND ...
Jonas Frei's user avatar
1 vote
0 answers
157 views

Problems with python GRASS module setup outside GRASS

I currently have GRASS version 78 installed with my OSGEO4W. I am trying to utilize the boilerplate instructions here to call the GRASS module in my python script outside of the GRASS console (ie in ...
gwydion93's user avatar
  • 1,821
2 votes
1 answer
461 views

How to fix "No module named grass.script" error in Linux PyCharm?

I'm trying to use v.generalize in the GRASS GIS library within a python code in PyCharm on my Linux Ubuntu system to make a shapefile that originally was a raster look less "blocky" by ...
user2031's user avatar
  • 211
1 vote
1 answer
59 views

Can't access rasters from PERMANENT mapset from Python

I'm having trouble accessing files from my PERMANENT mapset in the Python code editor inside GRASS. I am able to access the raster I would like to set my projection to from the console, but for some ...
Nabeel Rajabali's user avatar
1 vote
0 answers
81 views

Optimizing memory usage when running r.viewshed in GRASS

Short explanation: I am using r.viewshed as part of a script. The viewshed analysis is the most costly (time) part of the script and I'm trying to optimize how quickly it runs (I need to run the ...
Lauren K.'s user avatar
1 vote
0 answers
145 views

Errors Running Some Commands in GRASS Standalone Script

After much struggle I have managed to get a GRASS standalone script run outside of GRASS. I can successfully get an output from running some commands, while others give a very unclear and unhelpful ...
sobmortin's user avatar
1 vote
1 answer
406 views

Error while performing actions in GRASS GIS in Python

While performing actions in python console as described in the module of GRASS GIS,am getting following error: import grass.script as gs r.in.gdal -e input="D:...\ASTGTMV003_N19E073_dem" ...
Omkar Kadlag's user avatar
3 votes
0 answers
147 views

CalledModuleError: Module run None g.gisenv -n ended with error

I am trying to use r.horizon GRASS module(version GRASS 7.8) in Python script. But I couldn't able to access the grass modules. Everytime, I am getting the following error. File "C:\OSGEO4~1\apps\...
bs karthik reddy's user avatar
2 votes
0 answers
74 views

GRASS GIS: r.out.gdal raises an exception and hangs if it's called multiple consecutive times

I'm using a small python routine (grass.script, pygrass) to handle several operations on sentinel2 imagery. I'm calling r.out.gdal inside the script and a very annoying problem occurs: when it is ...
F.H.'s user avatar
  • 85
0 votes
1 answer
31 views

GRASS GIS 7.8 trigometric function of vector attribtue

I need to calculate the sin and cos of a vector attribute column, but these functions do not appear to be available. In Python I've tried using v.db.update: gscript.run_command('v.db.update', map='...
Forrest Williams's user avatar
1 vote
0 answers
228 views

GRASS GIS 7.8 Delete mapset from command line

Within GRASS GIS 7.8, a new mapset can be created using g.mapset -c mapset=mapset location=location, but is it possible to delete a mapset from the command line? I know that a mapset can be removed ...
Forrest Williams's user avatar
0 votes
1 answer
38 views

How to display graphics in IOS when connected remotely with Linux server?

I am trying to work using GRASS GIS for my data remotely from Mac. Here is what I have done: XQuartz was installed and run; Terminal was run. I typed: ssh -Y root@IPaddress Then I typed: grass64 (to ...
AngelaG's user avatar
  • 135
0 votes
0 answers
3k views

eval and cats is not recognized as an internal or external command, operable program or batch file in GRASS GIS

I'm trying to do the r.lfp and r.accumulate examples for multiple longest flow paths, except I keep getting the "eval" or "cats" "is not recognized as an internal or external ...
EnGIsNowhere's user avatar
0 votes
1 answer
69 views

r.green error installation on GRASS

I am using GRASS GIS 7.0.3 on linux, however I've been trying to install the r.green extension on GRASS and always get the error message: "ImportError: cannot import name set_path" "...
Anissa Nur Irmania's user avatar
0 votes
0 answers
41 views

Create a loop to run and store the r.stats output of several viewsheds?

I have 15 viewsheds (view 0-14) from which I would like to export the cell count. I can do this for one viewshed through: count=[] i=0 viewshedSize=grass.read_command("r.stats", overwrite=True,flags=...
grassgis1234's user avatar
1 vote
1 answer
54 views

run r.random through script in python shell

Trying to run r.random using the script but receiving an error message. It works when the module is run outside of the python shell so it must be te code, I'm new to this so I can't figure out what is ...
grassgis1234's user avatar
1 vote
0 answers
58 views

v.overlay with empty layer [closed]

I'm writing a Grass Python Script (using GRASS GIS 7.6.1) for a project for university. Sadly, I never learned Python, so it's a bit tricky but so far I got everything done I wanted to. The Script ...
Hamsley's user avatar
  • 11
0 votes
1 answer
66 views

Creating reclass-rules-textfile within Simple Python Editor of GRASS GIS

We are writing a script with the simple Python editor (GRASS GIS). We try to set the rules for a reclass command within the script (without creating a txt.file manually). Is it possible to set the ...
Eddi's user avatar
  • 1
1 vote
1 answer
207 views

GRASS GIS r.in.gdal, import multiple band ncdf

I am trying to import a ncdf file with 20000 bands (time steps of precipitation) to grass gis using r.in.gdal. My problem is that i dont need all the bands, only a portion of it, e.g : band 1 to band ...
Pablo Sanhueza 's user avatar
0 votes
1 answer
127 views

GRASS GIS: creating raster with a certain gradient and extent

Constraints - Use only GRASS GIS - Automated using pyGRASS Input DEM River raster OR river as vector (both are computed) gradient of the valley (as a float) vector line with direction and magnitude ...
MarcM's user avatar
  • 1,136
2 votes
1 answer
130 views

Creating cumulative friction map

I am looking at bottom friction (Manning's n) values in relation to storm surge as large volumes of water flow over a surface. In order to calculate total head loss occurring as water passes from the ...
Carter Rucker's user avatar
0 votes
0 answers
307 views

GRASS GIS: From multiple lines to single line

This seems like a simple process but somehow I am not able to solve this. The situation is as follows: I have three separate lines which form visually 1 line. As I want to further process these lines ...
MarcM's user avatar
  • 1,136
1 vote
0 answers
235 views

GRASS r.sun returns "ERROR: insol_time and incidout are incompatible options"

I'm trying to measure irradiance on a DEM using the r.sun tool in QGIS 3.6. I have grids for the elevation (EPSG:32735 - WGS 84 / UTM zone 35S), the slope and aspect (EPSG:4326 - WGS 84). I've tried ...
stephlynette612's user avatar
0 votes
0 answers
60 views

GRASS v.hull for many point sets

I have map "my_pointmap" with 3D points with ids=(1,2,3...N). I have also list of subsets of these point ids , S = [(1,2,3,4),(2,4,10,12), ...]. I would love to get GRASS GIS vector map with |S| 3D ...
vildead's user avatar
  • 231
1 vote
1 answer
160 views

Adding GRASS module to QGIS 2.18.21

I did a module in grass wich I called r.out.haralickFeatures.py. I did a .qgm. I can't get the parameters rigth. #!/usr/bin/env python #%module #% description: Compute asm, contrast, var, idm and ...
user123761's user avatar
0 votes
1 answer
545 views

Loading ADF file from National Elevation Dataset into GRASS with Python?

I'm trying to load data from the National Elevation Dataset into GRASS/Python, using this Python script (outside of GRASS): # Imports import os import grass_session from grass.script import setup as ...
Michael A's user avatar
  • 394
0 votes
1 answer
95 views

Entry point not found Error initiating GRASS GIS from Python

I cannot run any GRASS tools from within Python 2.7.15. While the GRASS environment, grass.script etc. are loading correctly and I can run basic checks like gscript.read_command('g.gisenv') gscript....
Hasnein Tareque's user avatar
2 votes
1 answer
905 views

Watershed Delineation Loop - r.water.outlet resulting in NAN area while snapped

I am attempting to create multiple watershed delineations for stations within a CSV file. I have files for flow direction (raster with a cell size of 30m), flow accumulation(raster with a cell size of ...
Nicole's user avatar
  • 21
3 votes
0 answers
66 views

GRASS GIS Error Flags

I am attempting to run a GRASS command from the terminal and eventually a bash script, in which it links rasters in a folder to the Mapset previously defined. I was able to successfully create the ...
TornadoEric's user avatar
2 votes
1 answer
223 views

grass GIS + spyder python script error

I'm getting crazy with grass gis and python. I want to call a grass function from an external python script (using spyder for instance). I've installed QGIS + GRASS with the OSGeo4W64 installation ...
hjordi's user avatar
  • 21
1 vote
1 answer
251 views

Setting variable from input map in GRASS python script?

I'm currently working on a GRASS script that takes maps from user input and computes them into a mapcalc expression. The issue i'm stucked with that when i ask for the map i can't set a variable name ...
Federico Gómez's user avatar
0 votes
1 answer
153 views

How to execute a GRASS module developed in Python?

I am following the FOSS4G-E 2015 tutorial on how to develop GRASS modules with Python. The minimum template given in this tutorial is this script: %%file r.viewshed.points.py #!/usr/bin/env python #%...
Luís de Sousa's user avatar
6 votes
2 answers
5k views

How to clip raster in GRASS GIS?

I am using GRASS GIS 7.2.0. The intent is to clip my DEM raster. I have searched available raster tools but didn't found anything allow me to clip my raster using polygon vector or interactively. How ...
Rex's user avatar
  • 1,178
1 vote
0 answers
41 views

(d.*) of GRASS GIS does not execute from standalone script

I am in windows 10. All my module import works well and grass env for standalone script is fine. I tried to execute following commands from standalone script. Neither wx1 display gets executed nor it ...
ang's user avatar
  • 11
1 vote
2 answers
539 views

How to calculate area of the output of r.water.outlet?

I wrote the following code to use r.water.outlet module in GRASS GIS: import os import sys #set up GRASS environment variables sys.path.append(os.path.join(os.environ['GISBASE'], 'etc', 'python')) ...
Heinz's user avatar
  • 1,525
0 votes
1 answer
262 views

Extracting raster information within/inside polygon (for each contour)

I have raster data of NDVI and DEM I have already created contour from DEM. Now I'm trying to find following: for each contour find the raster information within the contour. Can anyone suggest ...
user1234's user avatar
0 votes
1 answer
160 views

Possible to convert v.net.spanningtree to QGIS custom script so don't need GRASS installed?

Is it possible (and if yes then how or has this been done) to convert v.net.spanningtree in to a QGIS/python (custom) script that can be accessed in the QGIS graphical modeler in a way that GRASS is ...
guestagain's user avatar
2 votes
1 answer
2k views

Connecting Python script external to Grass GIS 7 program in Windows 10?

I've tried to find resources online to link and run my Python script externally from Grass GIS 7, however, I have not been successful. I found resources here that provide instructions (e.g., https://...
user3052817's user avatar
1 vote
0 answers
677 views

Use Function V.clean of the grass tool in a Python script

I need to integrate V.clean functionality of Grass in a script python. this functionnality is accessible in Qgis (Processing->tools). I found that I should use Grass API but I don't know the code ...
maryame's user avatar
  • 53
5 votes
3 answers
4k views

GRASS 7 environment setup for Python

I would like to use some GRASS functionality from a Python programme. With GRASS 6 this required the set up of various environment variables, as detailed in the GRASS Wiki. I am trying a similar ...
Luís de Sousa's user avatar
1 vote
1 answer
52 views

Problem with numeric variable in i.topo.corr

I have a script to do topographic correction on landsat images. Following the manual, I first have to create the illumination model. I do it with the following line: i.topo.corr -i --overwrite ...
ciskoh's user avatar
  • 165
2 votes
0 answers
249 views

GRASS GIS: how to run g.run_command("v.extract") in Python with sqlite, smooth-spline in GRASS GIS?

I would like to solve several problems by using a python script in GRASS GIS: I already uploaded collected GPS-waypoints and tracks ("v.in.org"), patched several GPS-vector data ("v.patch") and ...
khe's user avatar
  • 43
2 votes
1 answer
124 views

Pygrass reading raster issue

I'm tring to read a raster map from my grassData. I'm using this code import os import grass.script.setup as gsetup from grass.pygrass import raster gisbase = os.environ['GISBASE'] gisdbase = os....
Lorenzo Bottaccioli's user avatar