lmotta / polygonclickmap

QGIS Plugin - Polygon by clicking in map image.
GNU General Public License v2.0
7 stars 0 forks source link

Polygonizing error: Null geometry cannot be converted to a polygon. #1

Closed AlisterH closed 3 years ago

AlisterH commented 3 years ago

Hi, great plugin. There used to be another one for doing the same thing, but it had a complicated way of working, by exporting an image out to gimp to do the selection there, then bringing it back again.

It produces a python error if I press P without there being any areas to polygonise (i.e. without actually clicking on any areas, or if I click on some areas and then remove them before pressing P). This isn't very bad (although it should probably be avoided), and the plugin continues to function. But sometimes the error occurs even when there are some areas to polygonise, in which casethe situation becomes unrecoverable. I think the cause might be selecting an area that is fully contained within an area that has already been polygonised:


2021-09-07T14:36:15     WARNING    Traceback (most recent call last):
              File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\polygonclickmap\polygonclickmap.py", line 498, in keyReleaseEvent
              totalFeats = self.imageFlood.polygonizeFlood( self.layerFlood, self._getMetadata(), hasAdjustsBorder )
              File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\polygonclickmap\polygonclickmap.py", line 274, in polygonizeFlood
              g = adjustsBorder( g, layerFlood )
              File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\polygonclickmap\utils.py", line 321, in adjustsBorder
              result = getGeomAjustBorder( result, g )
              File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\polygonclickmap\utils.py", line 306, in getGeomAjustBorder
              rings = border.asPolygon()
             ValueError: Null geometry cannot be converted to a polygon.
AlisterH commented 3 years ago

There used to be another one for doing the same thing, but it had a complicated way of working, by exporting an image out to gimp to do the selection there, then bringing it back again.

Oh, looks like that plugin is yours too :)

lmotta commented 3 years ago

Yes, i am author Gimp plugin.

Thanks for test this plugin. I update the plugin, version 0.5, where, fixed the polygonization for, missing region and verification for adjust border.