1

I call using processing.alghelp("grass:r.to.vect")

I looked input:

 <ParameterRaster>
feature <ParameterSelection>
-s <ParameterBoolean>
GRASS_REGION_PARAMETER <ParameterExtent>
GRASS_OUTPUT_TYPE_PARAMETER <ParameterSelection>
output <OutputVector>


feature(Feature type)
    0 - line
    1 - point
    2 - area
GRASS_OUTPUT_TYPE_PARAMETER(v.out.ogr output type)
    0 - auto
    1 - point
    2 - line
    3 - area

then I try to do , processing.runalg("grass:r.to.vect" , iface.activeLayer,2, True, None,3,r"C:\Users\user2\Desktop\1\temp\drfsg\zhopa.shp")") but it returns an error, what I did wrong? the project is only one raster layer

Joseph
  • 75,746
  • 7
  • 171
  • 282
frontend33
  • 41
  • 8
  • You should use correct path-notation in strings: r"C:\Users\user2\Desktop\1\temp\drfsg" or "C:/Users/user2/Desktop/1/temp/drfsg" or "C:\Users\user2\Desktop\1\temp\drfsg" Don't know if thats the issue.. – Andreas Müller Feb 09 '17 at 09:42
  • that is not the way, it gives another error , 'int' object has no attribute 'split' – frontend33 Feb 09 '17 at 09:44
  • 1
    I think your GRASS_REGION_PARAMETER needs no int (your value is 2) but should be a string like it was used here: http://gis.stackexchange.com/questions/75666/how-to-call-processing-toolbox-in-qgis-python-console – Andreas Müller Feb 09 '17 at 09:58
  • processing.runalg("grass:r.to.vect" , iface.activeLayer,2, True, None,3,r"C:\Users\user2\Desktop\1\temp\drfsg\zhopa.shp") writing does not issue error, but nothing happens, does not work – frontend33 Feb 09 '17 at 10:05
  • if the code runs without an error than it is likely a problem with the dataset used. Data values, data size, for example. So please give more information about what you trying to achieve. – Andreas Müller Feb 09 '17 at 10:14
  • I have a raster, I want it to turn the console into a vector using, r.to.vect – frontend33 Feb 09 '17 at 10:21

1 Answers1

1

The recent QGIS versions have implemented GRASS7 into its processing framework as default so you may need to use grass7:r.to.vect instead of grass:r.to.vect. I have also experienced issues when trying to set the GRASS_REGION_PARAMETER to blank, instead I use the extents of the input layer as that's usually what I am interested in.

So you could try the following code into the python console:

from PyQt4.QtCore import QFileInfo
import processing

# Identify raster layer
raster = iface.activeLayer()
fileName = raster.source()
fileInfo = QFileInfo(fileName)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(fileName, baseName)

# Define the extent of the region
extent = rlayer.extent()
xmin = extent.xMinimum()
xmax = extent.xMaximum()
ymin = extent.yMinimum()
ymax = extent.yMaximum()

processing.runalg("grass7:r.to.vect",rlayer,2,True,"%f,%f,%f,%f"% (xmin, xmax, ymin, ymax),3,"C:/Users/user2/Desktop/1/temp/drfsg/zhopa.shp")
Joseph
  • 75,746
  • 7
  • 171
  • 282