geo_sim_processing icon indicating copy to clipboard operation
geo_sim_processing copied to clipboard

Problem using Chordal axis

Open mymysz opened this issue 3 years ago • 7 comments

Hi,

I would love to use the chordal axis tool but I encounter a problem : "for line in centre_lines: UnboundLocalError: local variable 'centre_lines' referenced before assignment"

I don't really understand a single thing about Python... so please help me !

Thank you :)

mymysz avatar May 23 '22 09:05 mymysz

Same issue here. I have Geo Simplification v1.2.0.

Upon examining the error, it seems that the code is catching an exception at chordal_axis_algorithm.py:192, and therefore not declaring the variable centre_lines, and after the code exits the try/except block, it tries to use the variable.

By moving the for line in centre_lines:block into the try, allows the program to finish the tessellation and generate results, but the chordal axis is an empty layer (because it generated an exception).

AdrianCarreno avatar Jun 14 '22 15:06 AdrianCarreno

Ran into the same problem on chordal axis. Tried following @AdrianCarreno suggestion along with some pass calls but would not write out the lines.

vovchykbratyk avatar Jul 28 '22 16:07 vovchykbratyk

@AdrianCarreno @vovchykbratyk @mymysz If you could provide me with a file (shape, Geo Package,...) that is bugging that would be helpful for the bug correction. Inlude also: QGIS version and OS version you are using. Thank you.

Dan-Eli avatar Sep 22 '22 21:09 Dan-Eli

Same issue here. QGIS Version:3.28.3-Firenze OS: Mac 12.2.1

bugging file(Roads of Bangkok, Thailand): OUT_TH_BIG_ROADS_POLYS.csv

joel-HOME avatar Feb 22 '23 13:02 joel-HOME

Thanks for the the CSV example. Did you got the same following error crash?

QGIS version: 3.28.0-Firenze QGIS code revision: ed3ad0430f3 Qt version: 5.15.3 Python version: 3.9.5 GDAL version: 3.5.2 GEOS version: 3.10.3-CAPI-1.16.1 PROJ version: Rel. 9.1.0, September 1st, 2022 PDAL version: 2.4.3 (git-version: 434757) Algorithm started at: 2023-02-22T22:44:10 Algorithm 'Chordal axis' starting… Input parameters: { 'CORRECTION' : False, 'INPUT' : 'C:/Users/dpilon/Downloads/OUT_TH_BIG_ROADS_POLYS.csv|geometrytype=Polygon|uniqueGeometryType=yes', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'TRIANGLES' : 'TEMPORARY_OUTPUT' }

Results: {'OUTPUT': 'output_0355f165_53d8_4a40_8c90_7da4db1aabcc'} Results: {'OUTPUT': 'output_d667af3f_80e4_4128_8a52_4ad14dabe3db'} Results: {'OUTPUT': 'output_cc9bf4ac_32fd_4980_94a2_d7d8f43275a3'} Traceback (most recent call last): File ".../Roaming/QGIS/QGIS3\profiles\default/python/plugins\geo_sim_processing\chordal_axis_algorithm.py", line 201, in processAlgorithm for line in centre_lines: UnboundLocalError: local variable 'centre_lines' referenced before assignment

Execution failed after 1.67 seconds

Dan-Eli avatar Feb 23 '23 02:02 Dan-Eli

The problem is reproduced here File "C:\Users/dpilon/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geo_sim_processing\chordal_axis_algorithm.py", line 1325, in adjacent_sides_ref xy = (mid_pnt_side.x, mid_pnt_side.y) AttributeError: 'QgsGeometry' object has no attribute 'x' is caused by the small dynamic value of the coordinates in the file . They are in lat-lon (probably) so between[-180:180], the problem come with the value used with the epsilon when we try to estimate what is 0. Presently it is a fix value set to 0.000001. It needs to be set dynamically or change the logic so not to rely on an epsilon value.

@AdrianCarreno @vovchykbratyk @mymysz @joel-HOME change your projection/EPSG to Web Mercator (3857) or any other projection/EPSG just for the Chordal Axis process and change it back to your original projection/EPSG after and it should work while I work on the problem.

Dan-Eli avatar Mar 02 '23 02:03 Dan-Eli

Now it works perfectly ! Thank you very much

mymysz avatar Mar 24 '23 09:03 mymysz