I'm trying to make a decision tree in PyQGIS, but I can't find anything in the API that helps me to get started. I am going to work with raster data of surveys, radiometrics, magnetometrics, surface temperature and other derivatives of DEM, but I need to do it automatically to facilitate work with other areas. I need to get a raster image that directs me to the areas where the parameters assigned to each image are met, I do this process in ENVI but now I have to do it in QGIS.

  • 1
    You need to flesh this question out a bit more. Where's your data coming from? What's the output going to look like? How are you specifying the decision tree, or do you want to fit one from data? Are there any existing python modules you want to integrate? Please edit your question. – Spacedman Apr 29 at 7:26
  • I added more detail to my question to show you more understanding of the work I want to do. Thank you – Manuel Guerra Apr 29 at 8:01

GRASS is good option for decision tree in QGIS. To perform this we can use r.mapcalculator (it provides a GUI frontend to r.mapcalc). Ok, we can see that the decision tree uses several conditions to discover what pixels it should classify in a specific class. This conditions are translated to GRASS using this:

if(x,a,b)               a if x not zero, b otherwise

So, to classify water (let’s say pixel value 0) to a class with value 5 and classify everything else to 255 we need to make this expression if(x,5,255), where x is the condition (e.g. image==0).

| improve this answer | |
  • but to take it to processing in PyQGIS I have to create a directory of Grass maps – Manuel Guerra Apr 29 at 8:50
  • yes, of course you need Grass – Rajendra Apr 29 at 17:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.