From a063facc99ce690854e54a30a5659459b2506cbf Mon Sep 17 00:00:00 2001
From: ptresson <paul.tresson@ird.fr>
Date: Wed, 20 Nov 2024 10:34:33 +0100
Subject: [PATCH] update common issues with rtree

---
 docs/featmap-dev.icons.rst | 10 -----
 docs/featmap-dev.rst       | 77 --------------------------------------
 docs/modules.rst           |  7 ----
 docs/source/issues.md      | 51 ++++++++++++++++++++++++-
 4 files changed, 50 insertions(+), 95 deletions(-)
 delete mode 100644 docs/featmap-dev.icons.rst
 delete mode 100644 docs/featmap-dev.rst
 delete mode 100644 docs/modules.rst

diff --git a/docs/featmap-dev.icons.rst b/docs/featmap-dev.icons.rst
deleted file mode 100644
index fbec9a0..0000000
--- a/docs/featmap-dev.icons.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-iamap\-dev.icons package
-==========================
-
-Module contents
----------------
-
-.. automodule:: iamap-dev.icons
-   :members:
-   :undoc-members:
-   :show-inheritance:
diff --git a/docs/featmap-dev.rst b/docs/featmap-dev.rst
deleted file mode 100644
index 02e85a8..0000000
--- a/docs/featmap-dev.rst
+++ /dev/null
@@ -1,77 +0,0 @@
-iamap\-dev package
-====================
-
-Subpackages
------------
-
-.. toctree::
-   :maxdepth: 4
-
-   iamap-dev.icons
-
-Submodules
-----------
-
-iamap\-dev.clustering module
-------------------------------
-
-.. automodule:: iamap-dev.clustering
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-iamap\-dev.encoder module
----------------------------
-
-.. automodule:: iamap-dev.encoder
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-iamap\-dev.iamap module
----------------------------
-
-.. automodule:: iamap-dev.iamap
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-iamap\-dev.provider module
-----------------------------
-
-.. automodule:: iamap-dev.provider
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-iamap\-dev.random\_forest module
-----------------------------------
-
-.. automodule:: iamap-dev.random_forest
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-iamap\-dev.reduction module
------------------------------
-
-.. automodule:: iamap-dev.reduction
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-iamap\-dev.similarity module
-------------------------------
-
-.. automodule:: iamap-dev.similarity
-   :members:
-   :undoc-members:
-   :show-inheritance:
-
-Module contents
----------------
-
-.. automodule:: iamap-dev
-   :members:
-   :undoc-members:
-   :show-inheritance:
diff --git a/docs/modules.rst b/docs/modules.rst
deleted file mode 100644
index f7c6c1d..0000000
--- a/docs/modules.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-iamap-dev
-===========
-
-.. toctree::
-   :maxdepth: 4
-
-   iamap-dev
diff --git a/docs/source/issues.md b/docs/source/issues.md
index dadb768..7cc282e 100644
--- a/docs/source/issues.md
+++ b/docs/source/issues.md
@@ -12,9 +12,58 @@
 <!-- ``` -->
 
 <!-- Then save the change, reload the plug-in and try again. -->
+## QGIS crashes at the start of encoding
+
+This is probably an issue with `rtree` during the creation of the dataset that will be used by the plugin.
+Indeed, depending on the installation, `rtree` and QGIS may have conflicting `libspatialindex`. Currently, there is several solutions:
+
+### 1. Uninstall `rtree` installed via pip and reinstall via package manager
+
+in the QGIS python console:
+
+(following code has not been tested, based on this [SE answer](https://gis.stackexchange.com/questions/418274/installing-python-module-using-pip-via-python-console-in-qgis-3-22))
+```
+import subprocess 
+import sys
+
+if sys.platform == 'win32':
+    subprocess.call([sys.exec_prefix + '/python', "-m", 'pip', 'unininstall', 'rtree'])
+else:
+    subprocess.call([sys.executable, '-m', 'pip', 'uninstall', 'rtree']) 
+```
+
+then in a terminal (for a debian based linux)
+
+```
+sudo apt-get install python3-rtree
+```
+
+### 2. Uninstall `rtree` installed via pip and reinstall `rtree` at an older version (<1.0.0)
+
+in the QGIS python console:
+
+(following code has not been tested, based on this [SE answer](https://gis.stackexchange.com/questions/418274/installing-python-module-using-pip-via-python-console-in-qgis-3-22))
+```
+import subprocess 
+import sys
+
+if sys.platform == 'win32':
+    subprocess.call([sys.exec_prefix + '/python', "-m", 'pip', 'unininstall', 'rtree'])
+    subprocess.call([sys.exec_prefix + '/python', "-m", 'pip', 'install', 'rtree==0.9'])
+else:
+    subprocess.call([sys.executable, '-m', 'pip', 'uninstall', 'rtree']) 
+    subprocess.call([sys.executable, "-m", 'pip', 'install', 'rtree==0.9'])
+```
+
+### 3. Use a conda environement.
+
+This way, rtree and qgis will automatically share the same libspatialindex.
+
+If you have any idea on how to solve this issue properly, do participate in the [corresponding issue](https://github.com/umr-amap/iamap/issues/13).
+
 
 ## Similarity or Random Forest causes QGIS to crash
 
 This crash is due to a bug during `geopandas` reading of a shapefile, only when it has allready read a shapefile. It is probably linked to `fiona` as well. If you have any idea on how to solve this, please do participate in the [corresponding issue](https://github.com/umr-amap/iamap/issues/28).
 
-In the meanwhile, if QGIS crashes and your file were not saved, you can still find them in the temp files like `/tmp/iamap_features` for instance.
+Meanwhile, if QGIS crashes and your file were not saved, you can still find them in the temp files like `/tmp/iamap_features` for instance.
-- 
GitLab