CSIRO-Precision-Agriculture / PAT_QGIS_Plugin

PAT is a QGIS plugin containing a collection of tools for processing precision agriculture data.
Other
25 stars 8 forks source link

Create strip trial points - issue #64

Closed JRichetti closed 1 year ago

JRichetti commented 1 year ago

I'm trying to create a strip trial points to run the moving t-test I'm getting the following error:

An error has occurred while executing Python code: 

UnboundLocalError: local variable 'out_crs' referenced before assignment 
Traceback (most recent call last):
  File "C:\Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\pat\gui\stripTrialPoints_dialog.py", line 190, in on_mcboLineLayer_layerChanged
    line_crs = get_UTM_Coordinate_System(layer.extent().xMinimum(),
  File "C:\Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\pat\util\qgis_common.py", line 71, in get_UTM_Coordinate_System
    if out_crs is not None:
UnboundLocalError: local variable 'out_crs' referenced before assignment

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] 
QGIS version: 3.22.9-Białowieża Białowieża, a8e9e6fa 

Python Path:
C:/PROGRA~1/QGIS32~1.9/apps/qgis-ltr/./python
C:/Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS32~1.9/apps/qgis-ltr/./python/plugins
C:\Program Files\QGIS 3.22.9\bin\python39.zip
C:\PROGRA~1\QGIS32~1.9\apps\Python39\DLLs
C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib
C:\Program Files\QGIS 3.22.9\bin
C:\Users\xxx\AppData\Roaming\Python\Python39\site-packages
C:\PROGRA~1\QGIS32~1.9\apps\Python39
C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib\site-packages
C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib\site-packages\win32
C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib\site-packages\Pythonwin
C:/Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\xxx\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plug

The raster and shape files were on WGS84. I tried converting it to a different CRS. Then the above error didn't show, but two other issues arised. One (not really a big deal) but the 'Lines Shapefile (Optinal)' was not really optional, I couldn't advance without setting it to be saved. The actual issue is that a different error shows up.

2022-08-18T14:56:04     INFO    **************************************************
             Processing Create strip trial points
2022-08-18T14:56:04     INFO    Parameters:---------------------------------------
              Line layer: baseline
              Distance between points (m): 5.0
              Line offset distance (m): 30.0
              Output coordinate system: EPSG:28350 - GDA94 / MGA zone 50
              Output points : C:\Users\ric375\OneDrive - CSIRO\Desktop\bars\baseline_strip-trial-points.shp
2022-08-18T14:56:05     CRITICAL    Cannot linemerge LINESTRING EMPTY
             Traceback (most recent call last):
              File "C:\Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\pat\gui\stripTrialPoints_dialog.py", line 396, in accept
              _ = create_points_along_line(gdf_lines, lines_desc.crs, self.dsbDistBtwnPoints.value(),
              File "C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib\site-packages\pyprecag\processing.py", line 1872, in create_points_along_line
              gdf_lines = GeoDataFrame(geometry=[linemerge(lines_geodataframe.unary_union)],
              File "C:\PROGRA~1\QGIS32~1.9\apps\Python39\lib\site-packages\shapely\ops.py", line 117, in linemerge
              raise ValueError("Cannot linemerge %s" % lines)
             ValueError: Cannot linemerge LINESTRING EMPTY

I'm running on Windows 10 - OS build 19044.1889 Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] QGIS version: 3.22.9-Białowieża Białowieża, a8e9e6fa

JRichetti commented 1 year ago

Looks like the new update fixed it.