1

I'm new to QGIS, and have never used the Python console. I have created a complex layer in QGis using an experimental, plugin which I had to manually install. It contains 91506 features; lines going around the country. I'm trying to run Q-chainage plugin to put points along these lines at regular intervals. I get the following error:

An error has occurred while executing Python code: 
AttributeError: 'NoneType' object has no attribute 'asPoint' 
Traceback (most recent call last):
  File "C:/Users/j6525/.qgis2/python/plugins\qchainage\qchainagedialog.py", line 124, in accept
    decimal)
  File "C:/Users/j6525/.qgis2/python/plugins\qchainage\chainagetool.py", line 199, in points_along_line
    divide)
  File "C:/Users/j6525/.qgis2/python/plugins\qchainage\chainagetool.py", line 69, in create_points_at
    point = QgsGeometry.fromPoint(point.asPoint())
AttributeError: 'NoneType' object has no attribute 'asPoint'

Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] 
QGIS version: 2.18.14 Las Palmas, ff83b9a479 
Python Path:
•   C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing
•   C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python
•   C:/Users/j6525/.qgis2/python
•   C:/Users/j6525/.qgis2/python/plugins
•   C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins
•   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\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\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/j6525/.qgis2//python
C:/Users/j6525/Desktop/GIS assessment/02_fields_of_conflict/02_fields_of_conflict
  • Does the plugin work for s simple dataset with a handful of features? – user30184 Dec 2 '17 at 20:52
  • Yes it does. This situation may be arising from Qchainage being applied to more than one island boundary. (Sea may be a null value). – SchoolBoy Dec 2 '17 at 21:41
  • 'NoneType' Error means that 'point' is of type 'None', so something before that line went wrong. I doubt we can help you here without knowing the code of the functions "points_along_line" and "create_points_at". And I think contacting the developer would be more helpful. – pLumo Dec 4 '17 at 8:41
  • You could try to avoid problematic geometries with adding if point is None: return None after point = geom.interpolate(startpoint) (of course properly aligned...) in C:/Users/j6525/.qgis2/python/plugins\qchainage\chainagetool.py Line 66. But I don't know if that produces some errors later on. – pLumo Dec 4 '17 at 8:52
  • This problem has been solved. – SchoolBoy Dec 6 '17 at 19:53
1

This problem has been solved.

the issue is that some lines are too short to create a point (because 2 points of the analysis were too close). This is a workaround: - Go to Vector -> Geometry Tools -> Check Validity - Select as input layer the one with the lcps and click Run (it can take a while for the battlefields) - Use the QChainage plugin on the "Valid output" new layer created by the previous step.

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.