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

create non-memory layer with processing plugin #32

Closed jagodki closed 6 years ago

jagodki commented 6 years ago

Hi Chris,

I have a problem using your plugin with the processing framework (the problem occurs using the processing plugin too). If I want to create a memory layer, the processing plugin works fine. But export the processing result to the filesystem will not work (I tried the file types Geopackage, GeoJSON and GML - all with the same problem). After the processing the protocol contains the hint, that the features cannot be written to the layer (see the screenshot below - but it is in German, sorry for that ^^'). The triangulation and the contouring should work, just the export to a layer directly to the filesystem is not working. The problem just occurs when I try to create a polygon layer (i.e. filled contours and layer polygons) - LineStrings can be exported into the named formats without problems. When I create polygons in a memory layer, the fields for [expression/field]_min and [expression/field]_max have the value 0.0 for each feature (see the next screenshot below). But the label field contains correct values. Because all three fields depends on the same variables in the ContourGenerator-class (that what I saw, maybe I didn't analyze the code correctly), it seems that there might be a problem with adding the features to the layer. I have not many experience with the QgsFeatureSink-class, maybe there is a problem? I tried to print attributes of the features to the python console (to check whether the features have correct values before exporting to the filesystem), but then QGIS crashes every time. That is very unusual, with my own plugins I can print each feature, layer etc. in big loops without crashing QGIS - maybe another problem?

Short conclusion:

Information about my system:

Let me know, if you need additional information from me about this problem (maybe the data I used or a complete description for reproducing the bug).

Sincerely, Christoph

P.S. and now the Screenshots :)

Protocol with the information, that the features cannot be written to the layer: bildschirmfoto 2018-07-05 um 06 16 21

The attribute table with incorrect values: bildschirmfoto 2018-07-02 um 05 49 30

ccrook commented 6 years ago

@jagodki Thanks Christoph. I have been able to reproduce the problem, so hopefully will get time to fix in the next day or two.

ccrook commented 6 years ago

@jagodki I have made some progress by sanitizing the output field names but more to be done. Creating geopackage works, but shapefile and geojson still don't. Also I have found a similar problem with some other plugins. For example convex hull failed to create features in the same way, where as layer from extent worked.
Update: convex hull failure was due to creating hull for point features, so failed with invalid geometries.

jagodki commented 6 years ago

@ccrook The export to GeoJSON could be problematic too, because the [expression/field]_min and [expression/field]_min fields are starting with a double quote. I am not sure, whether the processing framework can export the double quotes by escaping them with a backslash or not. If I try to export a layer containing a field with a starting double quote in its name manually into GeoJSON, QGIS escapes it. But maybe the processing framework works in a different way or it is a much general problem?

ccrook commented 6 years ago

That was the sanitizing of field names. I've fixed this on my dev machine but it is still not loading. I can export to geopackage and then save that as geojson without modification, so not sure what is happening in the OGR driver. To be investigated ...

ccrook commented 6 years ago

Running in debug version of QGIS identifies the following errors: src/core/qgsmessagelog.cpp: 27: (logMessage) [1ms] [thread:0x564e9710edc0] 2018-07-11T07:44:35 OGR[1] Invalid variant type for field z_min[1]: received PyQt_PyObject with type src/core/geometry/qgsgeos.cpp: 94: (printGEOSNotice) [1ms] [thread:0x564e9710edc0] GEOS notice: Interior is disconnected at or near point 40 20 Every feature is receiving invalid variant type for field z_min. Some have invalid geometry (known issue with matplotlib contour generation)

ccrook commented 6 years ago

@jagodki This should be fixed in version 2.0.6. Please let me know if you are still having problems. Thanks for identifying this issue.

jagodki commented 6 years ago

@ccrook The export to a non-memory layer works now. Thank you very much for fixing this bug. 👍