2

I'm trying to use the MMQGIS Distance to Nearest Hub tool but keep getting this error.

I'm on Windows 7, QGIS 2.18.2 and MMQGIS 2017.2.28. Any ideas?

An error has occurred while executing Python code: 

AttributeError: 'NoneType' object has no attribute 'boundingBox' 
Traceback (most recent call last):
File "C:/Users/EJO31/.qgis2/python/plugins\mmqgis\mmqgis_dialogs.py", line 1504, in run
   nameattributename, units, addlines, savename, evenly_distributed, 1)
File "C:/Users/EJO31/.qgis2/python/plugins\mmqgis\mmqgis_library.py", line 3816, in mmqgis_hub_distance
 wgs84_point = feature.geometry().boundingBox().center()
AttributeError: 'NoneType' object has no attribute 'boundingBox'


Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] 
QGIS version: 2.18.2 Las Palmas, 102ee87 

Python Path:
C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing
C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python
C:/Users/EJO31/.qgis2/python
C:/Users/EJO31/.qgis2/python/plugins
C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\nose-1.3.3-  py2.7.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\tornado-4.0.1-py2.7-win-amd64.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\backports.ssl_match_hostname-3.4.0.2-py2.7.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\certifi-14.05.14-py2.7.egg
C:\PROGRA~1\QGIS2~1.18\bin\python27.zip
C:\PROGRA~1\QGIS2~1.18\apps\Python27\DLLs
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\plat-win
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\lib-tk
C:\PROGRA~1\QGIS2~1.18\bin
C:\PROGRA~1\QGIS2~1.18\apps\Python27
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\PIL
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\jinja2-2.7.2-py2.7.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\markupsafe-0.23-py2.7-win-amd64.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\pytz-2012j-py2.7.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\win32
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\Pythonwin
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\Shapely-1.2.18-py2.7-win-amd64.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\wx-2.8-msw-unicode
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\xlrd-0.9.2-py2.7.egg
C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\xlwt-0.7.5-py2.7.egg
C:/Users/EJO31/.qgis2//python
C:\Users\EJO31\.qgis2\python\plugins\mmqgis/forms
C:/Users/EJO31/.qgis2/python/plugins\NNJoin
E:/Fixed Broadband Model/pcd_2_cab_2_exchange_data
4

you probably have EMPTY/NULL geometries. That error will occur if feature.geometry() is None.

wgs84_point = feature.geometry().boundingBox().center()
AttributeError: 'NoneType' object has no attribute 'boundingBox'

The plugin might not check for that edge case, so you'll need to create a subset of your data which does have a geometry. (For example, if you're using a delimited file, you'd get empty geometries if either/both of your latitude and longitude fields are empty)

  • I checked if there were any Empty/Null geometries but it didn't seem to be that. I removed all missing values in python before exporting coordinates as .csv and then I converted and saved the points into the current CRS. Finally, I tried $geometry IS NULL to select shapes with Empty/Null geometries but none were selected. Any other ideas? – Thirst for Knowledge Mar 14 '17 at 9:35
  • my apologies, I did find some hidden Empty/NULL geometries, which I have now removed and it worked. – Thirst for Knowledge Mar 14 '17 at 13:22
  • 1
    @ThirstforKnowledge, your Question, Steven's Answer and your Comments are very much appreciated. You helped me solve the puzzle that new geometries were connected to the previously made new entry, and the geometry of that was connected to the pre-previously. The error propagation was confusing, to say the least. – R'n'E Jul 13 '17 at 13:15
0

why this problem happenes. Because you have row(s) in the atribute table that don't have feature (graphical geometry). You can check this with a simple way. Select all feature from the layer and open the atribute table of the layer and look if all register (rows) has been selected, if not, edit table and exclude this rows without feature. After that maybe the Distance to nearest is going to work, I hope so.

why you have row in atribute table without feature? Maybe because you deleted in the wrong way...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.