qgis2web / qgis2web

QGIS plugin to export your project to an OpenLayers or Leaflet webmap. No server-side software required.
https://plugins.qgis.org/plugins/qgis2web/
GNU General Public License v2.0
585 stars 155 forks source link

Python error QGIS 3.12 #864

Closed myfta closed 4 years ago

myfta commented 4 years ago

Hi, I am using QGIS 3.12 and the latest version of qgis2web (3.13.0).

The OpenLayers version works but when I switch to Leaflet (which I want to use) just clicking "Update Preview" throws a Python error.

2020-04-08T21:47:49 WARNING Traceback (most recent call last): File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\maindialog.py", line 190, in changeFormat self.autoUpdatePreview() File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\maindialog.py", line 334, in autoUpdatePreview self.previewMap() File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\maindialog.py", line 337, in previewMap preview_file = self.createPreview() File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\maindialog.py", line 300, in createPreview dest_folder=utils.tempFolder()).index_file File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\leafletWriter.py", line 101, in write folder=dest_folder) File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\leafletWriter.py", line 272, in writeLeaflet useVT, useShapes, useOSMB) File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\leafletLayerScripts.py", line 129, in writeVectorLayer safeLayerName, feedback) File "C:/Users/graha/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\leafletLayerScripts.py", line 363, in getLegend for cnt, c in enumerate(classes): UnboundLocalError: local variable 'classes' referenced before assignment

Please advise. Thanks.

tomchadwin commented 4 years ago

One of your layers is using a style which qgis2web is not handling. Can you narrow your project down to a single layer which shows this error, and then upload that layer and your project file to this thread?

myfta commented 4 years ago

Hi,

I have done the testing as you hinted. I have discovered that one of my layers was using "Point cluster" for the Symbology. If I revert that to "Rule-based" the leaflet option works.

Happy to send the project if you still need it.

Thanks.

On Wed, 8 Apr 2020 at 22:26, Tom Chadwin notifications@github.com wrote:

One of your layers is using a style which qgis2web is not handling. Can you narrow your project down to a single layer which shows this error, and then upload that layer and your project file to this thread?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tomchadwin/qgis2web/issues/864#issuecomment-611203330, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALIWMNXIQGPD5PN64HFZZN3RLTTXZANCNFSM4MEHVQZQ .

tomchadwin commented 4 years ago

Thanks for the info - no, I don't need your files now. Yo uknow you can select "Cluster" within qgis2web? That should go some way to producing what you want. There is an open issue here to get rid of the qgis2web "Cluster" option, and instead activate it when the cluster renderer is selected:

https://github.com/tomchadwin/qgis2web/issues/377

I'll therefore close this issue, but thanks for reminding me of #377.

lpninja commented 1 year ago

Hi thanks for this great tool. I seem to be having a similar problem also but here is my error code. I have multi-geometry in my KML file that is loaded as 1 layer. I tried deleting that layer and QGIS2web worked. This issue is, I want to include this layer as this is the basis and purpose of my project. In google earth, you can split apart multi-point geometry, I am trying this but have to test it more.



KeyError: 7 
Traceback (most recent call last):
  File "/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/maindialog.py", line 348, in saveMap
    results = writer.write(self.iface,
  File "/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/leafletWriter.py", line 90, in write
    self.preview_file = self.writeLeaflet(
  File "/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/leafletWriter.py", line 189, in writeLeaflet
    exportVector(layer, safeLayerName, dataStore,
  File "/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/utils.py", line 245, in exportVector
    cleanLayer = writeTmpLayer(layer, restrictToExtent, iface, extent)
  File "/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/utils.py", line 172, in writeTmpLayer
    uri = TYPE_MAP[layer.wkbType()]
KeyError: 7

Python version: 3.8.7 (default, Feb 10 2021, 09:04:08) [Clang 12.0.0 (clang-1200.0.32.29)] 
QGIS version: 3.18.1-Zürich Zürich, 202f1bf7e5 

Python Path:
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/LAStools
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/contour
/Applications/QGIS.app/Contents/MacOS/../Resources/python
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/Fiona-1.8.13.post1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/affine-2.3.0-py3.8.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/statsmodels-0.11.1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/geopandas-0.8.1-py3.8.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/opencv_contrib_python-4.3.0.36-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/Rtree-0.9.4-py3.8.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/Pillow-7.2.0-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/lib-dynload
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/pyproj-2.6.0-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/numpy-1.20.1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/patsy-0.5.1-py3.8.egg
/Applications/QGIS.app/Contents/MacOS/lib/python38.zip
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/click_plugins-1.1.1-py3.8.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/scipy-1.5.1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/snuggs-1.4.7-py3.8.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/cftime-1.2.1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/GDAL-3.2.1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/netCDF4-1.5.4-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/numba-0.50.1-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/rasterio-1.1.5-py3.8-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.8/site-packages/pandas-1.1.0-py3.8-macosx-10.13.0-x86_64.egg
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web
/Users/4ths/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
..