Code Monkey home page Code Monkey logo

dzetsaka's Introduction

dzetsaka : classification tool

DOI

Inselberg in Guiana Amazonian Park

dzetsaka dzetsaka logo is very fast and easy to use but also a powerful classification plugin for Qgis. Initially based on Gaussian Mixture Model classifier developped by Mathieu Fauvel (now supports Random Forest, KNN and SVM), this plugin is a more generalist tool than Historical Map which was dedicated to classify forests from old maps. This plugin has by developped by Nicolas Karasiak.

A quick tutorial is available online (dzetsaka : how to make your first classification in qgis ?), or you can just download samples to test the plugin on your own.

What does dzetsaka mean ?

As this tool was developped during my work in the Guiana Amazonian Park to classify different kind of vegetation, I gave an Teko name (a native-american language from a nation which lives in french Guiana) which represent the objects we use to see the world through, such as satellites, microscope, camera...

Discover dzetsaka

dzetsaka : Classification tool runs with scipy library. You can download package like Spider by Anaconda for a very easy setup.

Then, as this plugin is very simple, you will just need two things for making a good classification :

  • A raster
  • A shapefile which contains your ROI (Region Of Interest)

The shapefile must have a column which contains your classification numbers (1,3,4...). Otherwise if you use text or anything else it certainly won't work.

Installation of scikit-learn

On Linux simply open terminal and type : python3 -m pip install scikit-learn -U --user

On Windows

For QGIS 3.20 and higher: Open OsGeo shell, then :

o4w_env

python3 -m pip install scikit-learn -U --user

For Qgis 3.18 and lower: Open OsGeo shell, then :

py3_env.bat

python3 -m pip install scikit-learn -U --user

Thanks to Alexander Bruy for the tip.

For Qgis 2: In the OsGeo setup, search for PIP and install it. Then you have few more steps to do. In the explorer, search for OsGeo4W Shell, right click to open it as an administrator. Now use pip in OsGeo Shell like on Linux. Just type :
pip install scikit-learn

If you do not have pip installed, open osgeo4w-setup-x86_64.exe, select Advanced install and install pip.

You can now use Random Forest, SVM, or KNN !

Tips

  • If your raster is spot6scene.tif, you can create your mask under the name spot6scene_mask.tif and the script will detect it automatically.
  • If you want to keep your spectral ROI model from an image, you can save your model to use it on another image.

Online dev documentation is available throught the doxygen branch.

Like us, use us ? Cite us !

If you use dzetsaka in your research and find it useful, please cite Dzetsaka using the following bibtex reference:

@misc{karasiak2016dzetsaka,
title={Dzetsaka Qgis Classification plugin},
author={Karasiak, Nicolas},
url={https://github.com/nkarasiak/dzetsaka},
year={2016},
doi={10.5281/zenodo.2552284}
}

Thanks to...

I would like to thank the Guiana Amazonian Park for their trust in my work, and the Master 2 Geomatics Sigma for their excellent lessons in geomatics.

Sponsors of Qgis

dzetsaka's People

Contributors

matt-needle avatar nkarasiak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dzetsaka's Issues

argument 1 has unexpected type 'float'

Hello everyone,

I tried the dzetsaka plugin, and what an incredible discovery!
However, before I could run the plugin correctly, I had to do a few things to make it work.

Context : Windows 11, QGIS 3.34.7, default installation, plugins (Quick OSM, dzetsaka, biodispersal, mergin maps, qgis2web, felt, groupstats, bee lines)

After installing the dzetsaka plugin supplements, with OSGeo4W, it gave me an error message : TypeError: setMaximum(self, maximum: int): argument 1 has unexpected type 'float'. To correct this error, I had to open the following file "progressBar.py", normally present in the plugin installation file, to then modify this line "prgBar.setMaximum(inMaxStep)", with this one "prgBar .setMaximum(int(inMaxStep))".
After this modification, the plugin worked correctly and displayed the automatic classification !

I remain at your disposal if you wish to discuss it,
Antoine

Training algorithm

Hi all,

Sorry in advance, I am pretty new to programming in general. For my research project, I am working on a SAR image, and I want to do supervised classifications on it to assess areas of water and non-water using training data I created in QGIS Lima. The image is quite big, so I Have broken it into smaller sample areas. I am currently running QGIS on mac OSX.

When running either the RF or SVM algorithm using the plugin. I receive these messages. Not sure where to go from here. If anyone has any advice, I would be deeply grateful.

Cheers,
Tim

Screen Shot 2024-03-06 at 8 27 40 PM

QGIS 3

Bonjour Nicolas,

is your tool compatible with QGIS 3?

dzetsaka tells of an nonexistent problem

Hi, Nicolas

I'm trying to run RF and I keep getting an error message asking me to make sure that my classes column has only integer values and that both my shapefile and raster have the same projection (EPSG:32616). However, both of these conditions are met by my files.

Where might the source of the problem be?

Changing training parameters

Thanks for your valuable work. Really user-friendly and useful plugin for remote sensing users. I want to ask a question. Can we change the parameters of classification algorithms? For example, can we change the number of threes for the Random Forest algorithm? It is important for experiments. Because sometimes changing these parameters is increasing the accuracy of the final results. Thanks.

dztsaka batch processing

I' a new user of dzetsaka algorithm, trying to do a svm classification using batch processing in qgis 3.16.0. I'm getting this log error messages. by the time when I use the classification dock it's run without problem with individual scenes
try fixing dzetsaka train algorithm

Can not use dzetsaka algorithms in models

I use Predict model (classification map) algorithm in my model and noticed very strange behavior. Algorithm added to the model, connected to inputs. But when model executed, next step failed because output from Predict model (classification map) algorithm does not passed correctly to the next algorithm.

Here is the model log execution log

Processing algorithm…
Algorithm 'test' starting…
Input parameters:
{ 'inputraster' : '/home/alex/datasets/test/raster.tif', 'dzetsakamodel' : '/home/alex/datasets/tree-inventory/RF-model.model', 'vectorzones' : '/home/alex/datasets/test/polygons.shp' }

Prepare algorithm: dzetsaka:Predict model (classification map)_1
Running Predict model (classification map) [1/2]
Input Parameters:
{ INPUT_MASK: , INPUT_MODEL: '/home/alex/datasets/tree-inventory/RF-model.model', INPUT_RASTER: '/home/alex/datasets/test/raster.tif', OUTPUT_RASTER: '/tmp/processing_8ecfcdea23904a36b83d2d6aeddfece2/caf41486cd744fd7b1212e0c35736a88/OUTPUT_RASTER.tif' }
OK. Execution took 23.972 s (1 outputs).
Prepare algorithm: qgis:zonalstatistics_1
Running Zonal statistics [2/2]
Input Parameters:
{ COLUMN_PREFIX: '_', INPUT_RASTER: None, INPUT_VECTOR: '/home/alex/datasets/test/polygons.shp', RASTER_BAND: 1, STATS: 9 }
Traceback (most recent call last):
File "/tmp/build/qgis/output/python/plugins/processing/algs/qgis/ZonalStatistics.py", line 132, in prepareAlgorithm
self.raster_interface = rasterLayer.dataProvider().clone()
AttributeError: 'NoneType' object has no attribute 'dataProvider'

Error encountered while running Zonal statistics
Error encountered while running Zonal statistics
Execution failed after 24.08 seconds

Loading resulting layers
Algorithm 'test' finished

As you can see, Zonal statistics algorithm gets None as input raster instead of raster layer/path. At the same time, output from dzetsaka exists and contains valid raster.

Test data (layers, project and model) attached. Any ideas what can be wrong here and how to fix it?
test.zip

SVM classification bug

Hi all,

I'm using this classification tool on MacOS with QGIS3.1 and it worked well with the Gaussian, RF and KNN methods but it remains stuck always at 83% for the SVM classification.

I also tried with the samples but same issue...

Does anyone has the same issue ?

Thank you !

Which are the default parameters on KNN and Random Forest?

How can I find out which were the parameters values used to do the classification, looking at the scripts, it seems to me that the program tests some values and choose the best suitable:

elif inClassifier == 'KNN':
from sklearn import neighbors

                **param_grid = dict(n_neighbors=np.arange(1, 20, 4))**
                if 'param_algo' in locals():
                    classifier = neighbors.KNeighborsClassifier(
                        **param_algo)
                else:
                    classifier = neighbors.KNeighborsClassifier()

How can I find out which value was used in my classification? I made it by default

failed install scikit-learn windows 10

i tried to install scikit-leart but it failed, message was :

C:\Windows\System32>pip install scikit-learn
Fatal error in launcher: Unable to create process using '"c:\osgeo41\bin\python3.exe" "C:\PROGRA1\QGIS3~1.4\apps\Python37\Scripts\pip.exe" install scikit-learn'

how to solve this problem, thank you

Please consider moving it under Processing

You'll save coding the interface, and the user will be able to integrate this into more complex workflows, having iterations, and much more.
Ask @volaya for howto, or have a look to other Processing plugins.

error when running classification

This is the error I am receiving:

2019-02-18T16:28:21	1	Traceback (most recent call last):
			  File "/Users/user/.qgis2/python/plugins/dzetsaka/dzetsaka.py", line 1114, in runMagic
			    temp.initPredict(inRaster,model,outRaster,inMask,confidenceMap,inClassifier)
			  File "/Users/user/.qgis2/python/plugins/dzetsaka/scripts/mainfunction.py", line 314, in initPredict
			    predictedImage=self.predict_image(inRaster,outRaster,tree,inMask,confidenceMap,-10000,SCALE=[M,m],classifier=classifier)
			UnboundLocalError: local variable 'tree' referenced before assignment

Failed to recognize scikit-learn in qgis 3.10.7 on Gentoo

Params:

$ uname -a
Linux ipee251 4.9.228-gentoo-x86_64-Shu #1 SMP PREEMPT Fri Jun 26 12:15:46 MSK 2020 x86_64 Intel(R) Core(TM) i5-3450 CPU @ 3.10GHz GenuineIntel GNU/Linux
$ eselect python list
Available Python interpreters, in order of preference:
  [1]   python3.7
  [2]   python2.7
  [3]   python3.8 (fallback)
$ eix -I learn
[I] sci-libs/scikits_learn
     Available:      ~0.19.0-r1^t ~0.20.2^t ~0.20.4^t 0.22.2_p1^t {examples test PYTHON_TARGETS="python3_6 python3_7 python3_8"}
     Installed:  0.22.2_p1^t(15:26:24 15.07.2020)(-examples -test PYTHON_TARGETS="python3_7 -python3_6 -python3_8")

The library scikit-learn is installed. Python by itself recognized it: when I tried to install scikit-learn via pip it warned me that '...already installed'. No error/warning messages in QGIS.

I'm absolutely nub in Python, so was stuck for a day. But then I simply copypasted line

from sklearn import metrics

to Python console and saw several errors ending with:

ModuleNotFoundError: no module named 'joblib'

And yes, dev-python/joblib wasn't installed! Installation of it and restarting QGIS allowed me to select Random Forest and others.

So it is not a real bug, but it will be nice just to write in README/greeting/etc about that requirement.

Failed to recognize scikit-learn in qgis 3.6 for ubuntu

When I tried to run SVM in qgis using the plugin, I got the library missing message "Scikit-learn library is missing on your computer." Although I have scikit-learn in my system:
Requirement already satisfied: scikit-learn in ./.local/lib/python3.6/site-packages (0.20.3)
Requirement already satisfied: scipy>=0.13.3 in ./.local/lib/python3.6/site-packages (from scikit-learn) (1.2.1)
Requirement already satisfied: numpy>=1.8.2 in ./.local/lib/python3.6/site-packages (from scikit-learn) (1.16.2)
How to let QGIS recognize the library?
System: ubuntu 18.04.
Try type:import sklearn in python console in qgis, it seems the scikit-learn is not installed in qgis.

No headers in matrix output

The output matrix would be enhanced by headers for (what I assume?) is the user and producer accuracy statistics generated. As it stands, there is uncertainty over exactly what the matrix values are reporting.

output model file format

Hey thanks for the plugin! I'm trying to test out the functionality of a few of the algorithms in QGIS 3.10, and am getting some strange results from my prediction map. I'm thinking it may be related to my output model from the train algorithm. What file format is the output model (in the train algorithm tool) supposed to be saved as?

Thanks,
Rob

Seeking feedback: QEP 179, Turning Plugin Management into Actual Package Management

I hope this is the right place to ask - my apologies if it is not: I am currently running a QGIS Enhancement Proposal (QEP) for turning plugin management into actual package management. As part of this process, I am looking for existing QGIS plugins and plugin developers who could significantly benefit from the proposed ideas and concepts. In a nutshell, I am proposing to allow to package QGIS plugins as regular Python wheels and/or conda packages - with all relevant packaging features such as proper Python package dependencies and binary extensions. Looking at this project's source code, it appears to be a good candidate for greatly benefiting from such features. If you find this work interesting and potentially relevant for your plugin, I am rather curious about your opinion. Among other issues, there appears to be some serious doubt about the existence of actual use cases for the proposed changes in QGIS among its core developers. Besides, the proposed work may also "confuse plugin developers". Feedback is therefore highly welcome.

Classifying with a trained model fails if a shapefile isn't selected

When i try to classify a raster file with a trained kNN model and i don't have at least one shapefile available i get the following error:

2019-05-20T09:54:03     WARNING    Traceback (most recent call last):
              File "C:/Users/USER/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\dzetsaka\dzetsaka.py", line 536, in runMagic
              inShape=inShape.dataProvider().dataSourceUri().split('|')[0] # Remove layerid=0 from SHP Path
             AttributeError: 'NoneType' object has no attribute 'dataProvider'
             
             During handling of the above exception, another exception occurred:
             
             Traceback (most recent call last):
              File "C:/Users/USER/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\dzetsaka\dzetsaka.py", line 556, in runMagic
              QgsMessageLog.logMessage('inShape is : '+inShape)
             TypeError: can only concatenate str (not "NoneType") to str

Having one shapefile available, even if not related to the classification, fixes this somehow.

Support for 4th band?

Using the Tool with a 4 band RGBI Image does not cause an error but the tool runs endlessly.
Would a 4 bandsupport be possible?

plugin in gqis2 for osx doesn't recognize scikit-learn

Trying to run random forest for qgis2 on osx with your plugin. Says it needs scikit-learn. Following instructions with pip I get
Requirement already satisfied: scikit-learn in ./anaconda2/lib/python2.7/site-packages

Yet the plugin doesn't recognize the installation.

Add macOS instructions to readme

There is no instruction available for macOS.

There is a pending pull request from #25 (tested with macOS 10.13.6 (High Sierra) and 10.15.5 (Catalina), QGIS 3.10.)
Also, there is an open issue #10 but related to qgis2.

Bug on MacOS

When we install scitkit-learn library and then the Dzetsaka plugin, QGIS opens several replicas, without ending, and we have to force quit them all. If we uninstall scitkit-learn library, the instalation of the plugin goes flawlessly. However, without the scitkit-learn library it will not work, as expected.

batch processing problem with train algorithm

I' a new user of dzetsaka algorithm, trying to do a svm classification using batch processing in qgis 3.16.0. I'm getting this log error messages. by the time when I use the classification dock it's run without problem with individual scenes
try fixing dzetsaka train algorithm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.