ccrook / QGIS-Contour-Plugin

Contour plugin for QGIS - uses python matplotlib to generate contours of data on vector point data.
43 stars 13 forks source link

ContourGenerator throws exception for NULL values #36

Closed Cord-Thomas closed 4 years ago

Cord-Thomas commented 4 years ago

I have a data source i really don't want to remove the NULL values from. Using a filter or a selection to remove them virtually, I cannot use the contour plugin. When i select the field that has the NULL values for the data value the plugin throws an exception.

I edited line 290 in ContourGenerator.py to read:

zval=float(zval or 0.0)

Not sure if that's the best approach but it solved my immediate problem

ccrook commented 4 years ago

Hi @Cord-Thomas Thanks for reporting this and for looking for a solution - glad if worked for you. I'm surprised neither I nor anyone else has hit this yet - seems a very likely situation.

In terms of solution I'd be inclined use a different approach, as a 0 value is very different from a null value. I'll look at inserting a line after 288

                zval=expression.evaluate(context)
                if zval is None:
                    continue

I haven't tested this yet, but it should work. I'm surprised using a filter or selection didn't work. I'm not sure why that is.

ccrook commented 4 years ago

@Cord-Thomas - hmmm. Didn't work in my test data set. Will have a solution shortly!

Cord-Thomas commented 4 years ago

I was surprised a bit as well. The problem stems from the inability to filter joined tables. It's my joined table that has nulls. Are you saying you are not seeing the problem or that my fix doesn't seem to resolve the confirmed issue.

ccrook commented 4 years ago

Fixed in version 2.0.8 @Cord-Thomas - this tests for QVariant.IsNull(), which is different to None. Thanks very much for taking the time to let me know about this.