Adding GRASS module to QGIS 2.18.21

by user123761   Last Updated August 14, 2018 16:22 PM

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 entr for each band of a TIFF file
#% keyword: raster
#% keyword: haralick
#% keyword: features
#%end

#%option G_OPT_F_BIN_INPUT
#% key: input
#% type: string
#% required : yes
#%end

#%option
#% key: size
#% type: integer
#% required: yes
#% multiple: no
#% key_desc: value
#% description: The size of moving window (odd and >= 3)
#% answer: 3
#%end

#%option
#% key: distance
#% type: integer
#% required: yes
#% multiple: no
#% key_desc: value
#% label: The distance between two samples (>= 1)
#% description: The distance must be smaller than the size of the moving window
#% answer: 1
#%end

#%option
#% key: categories
#% type: integer
#% description: Number of categories to rescale/recode the image
#% answer: 255
#% required : yes
#%end

#%flag
#% key: r
#% description: Rescales instead of recoding the image
#%end

#%option G_OPT_F_OUTPUT
#% key: output
#% type: string
#% required : no
#%end

import sys
import grass.script as gscript
from grass.pygrass.modules import Module, ParallelModuleQueue
from copy import deepcopy
from osgeo import gdal
import os
import time
import atexit

def main():
    options,flags = gscript.parser()
    inputFile = options['input']
    sizeMovingWindow = options['size']
    distance = options['distance']
    numCategories = options['categories']
    output = options['output']
    recode = flags['r']

    print options

    ...


if __name__ == '__main__':
    atexit.register(cleanup)
    main()

and the .qgm:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
<qgisgrassmodule label="Compute asm, contrast, var, idm and entr for each band of a TIFF file" module="r.out.haralickFeatures.py">
    <file key="input" />
    <option key="size" answer="3" type="integer" />
    <option key="distance" answer="1" type="integer" />
    <option key="categories" answer="255" type="integer" />
    <flag key="r" answer="off" />
    <file key="output" type="new" filters="Geo TIFF (*.tif *.tiff)"/>
</qgisgrassmodule>

The output i get after running it in qgis is:

C:/OSGEO4~1/apps/qgis-ltr/./grass/scripts/r.out.haralickFeatures.py 
input=C:/Users/Carolina/Documents/PPS/Informe/Landsat8-OLI.tif size=3 distance=1 categories=255 output=
{'input': '@[email protected]', 'output': '', 'distance': '1', 'categories': '255', 'size': '3'}

ERROR: Unable to open file:  @[email protected]

Successfully finished

Anybody knows why i get @[email protected] and not the parameters i'm supposed to get?



Related Questions



grass GIS + spyder python script error

Updated January 23, 2018 17:22 PM


GRASS GIS Error Flags

Updated May 12, 2018 16:22 PM

Topology in QGIS

Updated February 21, 2018 19:22 PM