We have built a website which takes features with attributes from a database, reconstructs the features using pyGPlates on the server and returns them to a map and as json.
We bumped into a bug. If an attribute of the first data point has a value null this attribute is ignored for all features, even if those do have a non-null value. We can implement a work around (replace null with a dummy), but this behaviour is unwanted. I can send test code, with sample inputs of different cases.
Thanks for the test files and code to reproduce the issue. That helped Michael and I to locate the issue.
As Michael noted, the problem happens when saving to an OGR format file (eg, Shapefile, OGRGMT) but the attributes are correctly loaded when reading an OGR file (before saving).
This affects pyGPlates and GPlates alike.
I just fixed it for saving but not yet exporting (which is the code path that pygplates.reconstruct() uses). Once that’s done I’ll PM you the source code (to compile on Ubuntu and test).
Regards,
John
For reference: It turned out that the attribute field names were collected from the first feature in the collection, which explains why your ‘_with_null_and_data’ file has problems (ie, it’s first feature has a null, followed by three non-nulls). Another thing which may or may not affect things is Ubuntu 16.04 uses GDAL < 2.2. With GDAL >= 2.2 we can read/write null properly. In other words Ubuntu 18.04 (GDAL 2.2) handles null better - but I’m not sure if this will affect your issue. So just flagging it for reference.
For reference:
I found a solution in adding a dummy feature before all others with all attributes having a value and removing this dummy feature after reconstruction.