coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.
MIT License
199 stars 26 forks source link

Segmentation error "The WKT could not be parsed" #38

Closed JOMahony-dot closed 3 months ago

JOMahony-dot commented 3 months ago

Hello, I was wondering if I could get help. I have been using Geo-SAM for a while without any problems. But recently I updated my QGIS and have gotten the following error. I have followed the steps I have used before and was able to segment my own images after being processed. But now when I try to segment my processed image I get the following error. Is there something obvious that I'am doing wrong? Any help would be greatly appreciated.

  1. An error has occurred while executing Python code:
  2. rasterio.errors.CRSError: The WKT could not be parsed. OGR Error code 5
  3. Traceback (most recent call last):
  4. File "rasterio/crs.pyx", line 775, in rasterio.crs.CRS.from_user_input
  5. File "rasterio/_err.pyx", line 209, in rasterio._err.exc_wrap_ogrerr
  6. rasterio._err.CPLE_BaseError: OGR Error code 5
  7. During handling of the above exception, another exception occurred:
  8. Traceback (most recent call last):
  9. File "/Users/james/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/geo_sam_tool.py", line 403, in execute_segmentation
  10. if not self.sam_model.sam_predict(
  11. File "/Users/james/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/tools/SAMTool.py", line 94, in sam_predict
  12. self.sample = self.test_features[query]
  13. File "/Users/james/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/tools/torchgeo_sam.py", line 356, in getitem
  14. vrt_fh = self._load_warp_file(filepath)
  15. File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/torchgeo/datasets/geo.py", line 592, in _load_warp_file
  16. vrt = WarpedVRT(src, crs=self.crs)
  17. File "rasterio/_warp.pyx", line 947, in rasterio._warp.WarpedVRTReaderBase.init
  18. File "rasterio/crs.pyx", line 777, in rasterio.crs.CRS.from_user_input
  19. rasterio.errors.CRSError: The WKT could not be parsed. OGR Error code 5
  20. Python version: 3.9.5 (default, Sep 10 2021, 16:18:19) [Clang 12.0.5 (clang-1205.0.22.11)]
  21. QGIS version: 3.36.0-Maidenhead Maidenhead, 09951dc0acf
  22. Python Path:
  23. /Applications/QGIS.app/Contents/MacOS/../Resources/python
  24. /Users/james/Library/Application Support/QGIS/QGIS3/profiles/default/python
  25. /Users/james/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
  26. /Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins
  27. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/pyproj-3.2.0-py3.9-macosx-10.13.0-x86_64.egg
  28. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/patsy-0.5.1-py3.9.egg
  29. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/numba-0.50.1-py3.9-macosx-10.13.0-x86_64.egg
  30. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/opencv_contrib_python-4.3.0.36-py3.9-macosx-10.13.0-x86_64.egg
  31. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/scipy-1.5.1-py3.9-macosx-10.13.0-x86_64.egg
  32. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/geopandas-0.8.1-py3.9.egg
  33. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/lib-dynload
  34. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/cftime-1.2.1-py3.9-macosx-10.13.0-x86_64.egg
  35. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/netCDF4-1.5.4-py3.9-macosx-10.13.0-x86_64.egg
  36. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages
  37. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/statsmodels-0.11.1-py3.9-macosx-10.13.0-x86_64.egg
  38. /Applications/QGIS.app/Contents/MacOS/lib/python3.9
  39. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/GDAL-3.3.2-py3.9-macosx-10.13.0-x86_64.egg
  40. /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/pandas-1.3.3-py3.9-macosx-10.13.0-x86_64.egg
  41. /Applications/QGIS.app/Contents/MacOS/lib/python39.zip
  42. /Users/james/Library/Application Support/QGIS/QGIS3/profiles/default/python

.

JOMahony-dot commented 3 months ago

![Uploading Screenshot 2024-03-08 at 15.57.01.png…]()

JOMahony-dot commented 3 months ago

@Fanchengyan

Fanchengyan commented 3 months ago

Hi @JOMahony-dot ,

This issue should be irrelevant to the QGIS version. It is likely caused by the discrepancy between the feature CRS in the prompt location and the first recognized feature file, which results in an error during loading. I guess you might have put different encoded features into one folder, and when giving feature path in Geo-SAM, the feature path was not specific enough?

JOMahony-dot commented 3 months ago

Hi @Fanchengyan,

Apologies for the late response. But yes this was the problem and it now works fine.

Thank you!