BjornNyberg / Geometric-Attributes-Toolbox

The Geometric Attributes toolbox is a set of QGIS tools designed for the geometric attribute and shape characterization of modern depositional elements
GNU General Public License v3.0
74 stars 8 forks source link

'NoneType' object error running script in QGIS 3.10 #5

Closed davidadbo closed 4 years ago

davidadbo commented 4 years ago

I am using QGIS 3.10 and am attempting to obtain center lines of a polygon layer using the geometry plug in. I have previously fixed all the polygons and re-checked their validity, there are no errors. I get the following error when running the script on the whole layer or a selected polygon from that layer.

The error is line 141, in processAlgorithm field_check =layer.fields().indexFromName('ID') AttributeError: 'NoneType' object has no attribute 'fields'

I have selected all polygons and confirmed there are no other rows in the attribute table. The layer is projected. The attribute table contains fid, DN(all values=1), Value (random value for each polygon) and ID, added using the $id option under 'record' in populating a a new field. The ID filed was not present originally.

I confirmed that the plugin worked on a separate simple polygon. I attach a small extract of the file.

2VD_polygon_extract.zip

BjornNyberg commented 4 years ago

@davidadbo thanks for pointing our this problem. I was able to reproduce the error if you use the 'selected features only' option available below the feature layer input. If so, this is a feature that needs to be added at some point but is not implemented at the moment. If you wish to only run the example on a few polygons, i suggest saving this file as a seperate feature layer atm.

davidadbo commented 4 years ago

Thank you for your reply.

I went to selected because it crashes QGIS if there are many polygons. If I extract a few at a time, then it works.

From: BjornNyberg notifications@github.com Sent: April 26, 2020 2:48 AM To: BjornNyberg/Geometric-Attributes-Toolbox Geometric-Attributes-Toolbox@noreply.github.com Cc: davidadbo davidad@shaw.ca; Mention mention@noreply.github.com Subject: Re: [BjornNyberg/Geometric-Attributes-Toolbox] 'NoneType' object error running script in QGIS 3.10 (#5)

@davidadbo https://github.com/davidadbo thanks for pointing our this problem. Do you have the 'selected feature only' option checked? If so, this is a feature that needs to be added at some point but is not implemented at the moment. If you wish to only run the example on a few polygons, i suggest saving this file as a seperate feature layer atm.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BjornNyberg/Geometric-Attributes-Toolbox/issues/5#issuecomment-619519754 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AMTDCKJL7W3LH6ESEQTAYRTROP7MHANCNFSM4MQ6DU2A . https://github.com/notifications/beacon/AMTDCKONAKBYBKOXXAJIKI3ROP7MHA5CNFSM4MQ6DU2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOETWR6CQ.gif

BjornNyberg commented 4 years ago

@davidadbo I have added a temporary solution that will do the analyses on the selected features. Note that you should not use the 'selected feature only' option. Please reinstall the plugin from the plugin manager.

In addition ive internally added options to densify and simplify the polygon geometry that should help with creating centerlines of very complex polygons.

davidadbo commented 4 years ago

Thanks for your attention to this.

I re-loaded the plugin and created an extract with 800 records (polygons). I assume you are suggesting selecting one or more polygons using the toolbar select which I did for one polygon. It crashes QGIS. If I try to execute the script on the whole layer, it also crashes. I can get the script to work on one extracted polygon in its own layer. I haven’t tried more than one. I am not sure if it’s the number of polygons or something about one or more of them that causes the crash. The polygons were originally created using the raster to vector tool on the Boolean output value = 1 from a raster calculator query. The geometries were then fixed using ‘fix geometries’.

The main objective I have in creating centrelines is to use these lines along with the profile plugin to generate profiles of rasters where the z field is a value (in my case electromagnetic responses at different frequencies). When I create the centre line using the geometric attributes plugin, there are still a number of lines present that are perpendicular to the centre line of the polygon. I can edit these out manually for each line to leave one centre line. However, it looks like the order of points along the centre line is not along the line from start to end so it generates an unexpected and incorrect profile. If I digitize a line and snap to the created centreline and then use the digitized line in the profile tool, the profile is fine. So I have a workaround on a case by case basis but less so for multiple polygons.

From: BjornNyberg notifications@github.com Sent: April 27, 2020 3:09 AM To: BjornNyberg/Geometric-Attributes-Toolbox Geometric-Attributes-Toolbox@noreply.github.com Cc: davidadbo davidad@shaw.ca; Mention mention@noreply.github.com Subject: Re: [BjornNyberg/Geometric-Attributes-Toolbox] 'NoneType' object error running script in QGIS 3.10 (#5)

@davidadbo https://github.com/davidadbo I have added a temporary solution that will do the analyses on the selected features. Note that you should not use the 'selected feature only' option. Please reinstall the plugin from the plugin manager.

In addition ive internally added options to densify and simplify the polygon geometry that should help with creating centerlines of very complex polygons.

— You are receiving this because you were mentioned. Reply to this email directly, https://github.com/BjornNyberg/Geometric-Attributes-Toolbox/issues/5#issuecomment-619878857 view it on GitHub, or https://github.com/notifications/unsubscribe-auth/AMTDCKNV3MZDZBFQDEFNTITROVKTTANCNFSM4MQ6DU2A unsubscribe.

BjornNyberg commented 4 years ago

@davidadbo The creation of centerlines from polygons is computationally very expensive as it needs to consider every vertex in the feature layer. If you are using a raster to begin with I would suggest using the Raster tools provided within the Geometric Attributes to create centerlines and then sample those transects. The order of points in the centerline are from start to end if there is only one start and one endpoint (i.e. using the 'Centerlines' Method).

As for the method that the profiler plugin uses im not sure but the sample transects tool in Geomtric Attributes will extract data according to the Distance field. Nonetheless, considering this does not seem to be a bug with the plugin im going to close this issue but feel free to reopen if the original issue persists. If you would like to discuss more about methodology and the one I use for sampling transects feel free to contact me directly at my email address - bjorn.nyberg@uib.no